call_code = Handle(isolate->builtins()->builtin(call)); Handle function = prototype.is_null() ? factory->NewFunctionWithoutPrototype(internalized_name, call_code) : factory->NewFunctionWithPrototype(internalized_name, type, instance_size, prototype, call_code, install_initial_map); PropertyAttributes attributes; if (target->IsJSBuiltinsObject()) { attributes = static_cast(DONT_ENUM | DONT_DELETE | READ_ONLY); } else { attributes = DONT_ENUM; } CHECK_NOT_EMPTY_HANDLE(isolate, JSObject::SetLocalPropertyIgnoreAttributes( target, internalized_name, function, attributes)); if (set_instance_class_name) { function->shared()->set_instance_class_name(*internalized_name); } function->shared()->set_native(true); return function; } void Genesis::SetFunctionInstanceDescriptor( Handle map, PrototypePropertyMode prototypeMode) { int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5; Handle descriptors(factory()->NewDescriptorArray(0, size)); DescriptorArray::WhitenessWitness witness(*descriptors); Handle length(factory()->NewForeign(&Accessors::FunctionLength)); Handle name(factory()->NewForeign(&Accessors::FunctionName)); Handle args(factory()->NewForeign(&Accessors::FunctionArguments)); Handle caller(factory()->NewForeign(&Accessors::FunctionCaller)); Handle prototype; if (prototypeMode != DONT_ADD_PROTOTYPE) { prototype = factory()->NewForeign(&Accessors::FunctionPrototype); } PropertyAttributes attribs = static_cast( DONT_ENUM | DONT_DELETE | READ_ONLY); map->set_instance_descriptors(*descriptors); { // Add length. CallbacksDescriptor d(*factory()->length_string(), *length, attribs); map->AppendDescriptor(&d, witness); } { // Add name. CallbacksDescriptor d(*factory()->name_string(), *name, attribs); map->AppendDescriptor(&d, witness); } { // Add arguments. CallbacksDescriptor d(*factory()->arguments_string(), *args, attribs); map->AppendDescriptor(&d, witness); } { // Add caller. CallbacksDescriptor d(*factory()->caller_string(), *caller, attribs); map->AppendDescriptor(&d, witness); } if (prototypeMode != DONT_ADD_PROTOTYPE) { // Add prototype. if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) { attribs = static_cast(attribs & ~READ_ONLY); } CallbacksDescriptor d(*factory()->prototype_string(), *prototype, attribs); map->AppendDescriptor(&d, witness); } } Handle Genesis::CreateFunctionMap(PrototypePropertyMode prototype_mode) { Handle map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); SetFunctionInstanceDescriptor(map, prototype_mode); map->set_function_with_prototype(prototype_mode != DONT_ADD_PROTOTYPE); return map; } Handle Genesis::CreateEmptyFunction(Isolate* isolate) { // Allocate the map for function instances. Maps are allocated first and their // prototypes patched later, once empty function is created. // Functions with this map will not have a 'prototype' property, and // can not be used as constructors. Handle function_without_prototype_map = CreateFunctionMap(DONT_ADD_PROTOTYPE); native_context()->set_function_without_prototype_map( *function_without_prototype_map); // Allocate the function map. This map is temporary, used only for processing // of builtins. // Later the map is replaced with writable prototype map, allocated below. Handle function_map = CreateFunctionMap(ADD_READONLY_PROTOTYPE); native_context()->set_function_map(*function_map); // The final map for functions. Writeable prototype. // This map is installed in MakeFunctionInstancePrototypeWritable. function_map_writable_prototype_ = CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE); Factory* factory = isolate->factory(); Handle object_name = factory->Object_string(); { // --- O b j e c t --- Handle object_fun = factory->NewFunction(object_name, factory->null_value()); Handle object_function_map = factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); object_fun->set_initial_map(*object_function_map); object_function_map->set_constructor(*object_fun); native_context()->set_object_function(*object_fun); // Allocate a new prototype for the object function. Handle prototype = factory->NewJSObject( isolate->object_function(), TENURED); native_context()->set_initial_object_prototype(*prototype); // For bootstrapping set the array prototype to be the same as the object // prototype, otherwise the missing initial_array_prototype will cause // assertions during startup. native_context()->set_initial_array_prototype(*prototype); Accessors::FunctionSetPrototype(object_fun, prototype); } // Allocate the empty function as the prototype for function ECMAScript // 262 15.3.4. Handle empty_string = factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("Empty")); Handle empty_function = factory->NewFunctionWithoutPrototype(empty_string, CLASSIC_MODE); // --- E m p t y --- Handle code = Handle(isolate->builtins()->builtin( Builtins::kEmptyFunction)); empty_function->set_code(*code); empty_function->shared()->set_code(*code); Handle source = factory->NewStringFromOneByte(STATIC_ASCII_VECTOR("() {}")); Handle 登录后可以享受更多权益 您还没有登录,登录后您可以: 收藏Android系统代码 收藏喜欢的文章 多个平台共享账号 去登录 首次使用?从这里 注册
(isolate->builtins()->builtin(call)); Handle function = prototype.is_null() ? factory->NewFunctionWithoutPrototype(internalized_name, call_code) : factory->NewFunctionWithPrototype(internalized_name, type, instance_size, prototype, call_code, install_initial_map); PropertyAttributes attributes; if (target->IsJSBuiltinsObject()) { attributes = static_cast(DONT_ENUM | DONT_DELETE | READ_ONLY); } else { attributes = DONT_ENUM; } CHECK_NOT_EMPTY_HANDLE(isolate, JSObject::SetLocalPropertyIgnoreAttributes( target, internalized_name, function, attributes)); if (set_instance_class_name) { function->shared()->set_instance_class_name(*internalized_name); } function->shared()->set_native(true); return function; } void Genesis::SetFunctionInstanceDescriptor( Handle map, PrototypePropertyMode prototypeMode) { int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5; Handle descriptors(factory()->NewDescriptorArray(0, size)); DescriptorArray::WhitenessWitness witness(*descriptors); Handle length(factory()->NewForeign(&Accessors::FunctionLength)); Handle name(factory()->NewForeign(&Accessors::FunctionName)); Handle args(factory()->NewForeign(&Accessors::FunctionArguments)); Handle caller(factory()->NewForeign(&Accessors::FunctionCaller)); Handle prototype; if (prototypeMode != DONT_ADD_PROTOTYPE) { prototype = factory()->NewForeign(&Accessors::FunctionPrototype); } PropertyAttributes attribs = static_cast( DONT_ENUM | DONT_DELETE | READ_ONLY); map->set_instance_descriptors(*descriptors); { // Add length. CallbacksDescriptor d(*factory()->length_string(), *length, attribs); map->AppendDescriptor(&d, witness); } { // Add name. CallbacksDescriptor d(*factory()->name_string(), *name, attribs); map->AppendDescriptor(&d, witness); } { // Add arguments. CallbacksDescriptor d(*factory()->arguments_string(), *args, attribs); map->AppendDescriptor(&d, witness); } { // Add caller. CallbacksDescriptor d(*factory()->caller_string(), *caller, attribs); map->AppendDescriptor(&d, witness); } if (prototypeMode != DONT_ADD_PROTOTYPE) { // Add prototype. if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) { attribs = static_cast(attribs & ~READ_ONLY); } CallbacksDescriptor d(*factory()->prototype_string(), *prototype, attribs); map->AppendDescriptor(&d, witness); } } Handle Genesis::CreateFunctionMap(PrototypePropertyMode prototype_mode) { Handle map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); SetFunctionInstanceDescriptor(map, prototype_mode); map->set_function_with_prototype(prototype_mode != DONT_ADD_PROTOTYPE); return map; } Handle Genesis::CreateEmptyFunction(Isolate* isolate) { // Allocate the map for function instances. Maps are allocated first and their // prototypes patched later, once empty function is created. // Functions with this map will not have a 'prototype' property, and // can not be used as constructors. Handle function_without_prototype_map = CreateFunctionMap(DONT_ADD_PROTOTYPE); native_context()->set_function_without_prototype_map( *function_without_prototype_map); // Allocate the function map. This map is temporary, used only for processing // of builtins. // Later the map is replaced with writable prototype map, allocated below. Handle function_map = CreateFunctionMap(ADD_READONLY_PROTOTYPE); native_context()->set_function_map(*function_map); // The final map for functions. Writeable prototype. // This map is installed in MakeFunctionInstancePrototypeWritable. function_map_writable_prototype_ = CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE); Factory* factory = isolate->factory(); Handle object_name = factory->Object_string(); { // --- O b j e c t --- Handle object_fun = factory->NewFunction(object_name, factory->null_value()); Handle object_function_map = factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); object_fun->set_initial_map(*object_function_map); object_function_map->set_constructor(*object_fun); native_context()->set_object_function(*object_fun); // Allocate a new prototype for the object function. Handle prototype = factory->NewJSObject( isolate->object_function(), TENURED); native_context()->set_initial_object_prototype(*prototype); // For bootstrapping set the array prototype to be the same as the object // prototype, otherwise the missing initial_array_prototype will cause // assertions during startup. native_context()->set_initial_array_prototype(*prototype); Accessors::FunctionSetPrototype(object_fun, prototype); } // Allocate the empty function as the prototype for function ECMAScript // 262 15.3.4. Handle empty_string = factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("Empty")); Handle empty_function = factory->NewFunctionWithoutPrototype(empty_string, CLASSIC_MODE); // --- E m p t y --- Handle code = Handle(isolate->builtins()->builtin( Builtins::kEmptyFunction)); empty_function->set_code(*code); empty_function->shared()->set_code(*code); Handle source = factory->NewStringFromOneByte(STATIC_ASCII_VECTOR("() {}")); Handle 登录后可以享受更多权益 您还没有登录,登录后您可以: 收藏Android系统代码 收藏喜欢的文章 多个平台共享账号 去登录 首次使用?从这里 注册
code = Handle(isolate->builtins()->builtin( Builtins::kEmptyFunction)); empty_function->set_code(*code); empty_function->shared()->set_code(*code); Handle source = factory->NewStringFromOneByte(STATIC_ASCII_VECTOR("() {}")); Handle 登录后可以享受更多权益 您还没有登录,登录后您可以: 收藏Android系统代码 收藏喜欢的文章 多个平台共享账号 去登录 首次使用?从这里 注册
(isolate->builtins()->builtin( Builtins::kEmptyFunction)); empty_function->set_code(*code); empty_function->shared()->set_code(*code); Handle source = factory->NewStringFromOneByte(STATIC_ASCII_VECTOR("() {}")); Handle 登录后可以享受更多权益 您还没有登录,登录后您可以: 收藏Android系统代码 收藏喜欢的文章 多个平台共享账号 去登录 首次使用?从这里 注册
您还没有登录,登录后您可以:
首次使用?从这里 注册