call_code = Handle(isolate->builtins()->builtin(call)); Handle prototype; Handle function = maybe_prototype.ToHandle(&prototype) ? factory->NewFunction(internalized_name, call_code, prototype, type, instance_size) : factory->NewFunctionWithoutPrototype(internalized_name, call_code); PropertyAttributes attributes; if (target->IsJSBuiltinsObject()) { attributes = static_cast(DONT_ENUM | DONT_DELETE | READ_ONLY); } else { attributes = DONT_ENUM; } JSObject::SetOwnPropertyIgnoreAttributes( target, internalized_name, function, attributes).Check(); if (target->IsJSGlobalObject()) { function->shared()->set_instance_class_name(*internalized_name); } function->shared()->set_native(true); return function; } void Genesis::SetFunctionInstanceDescriptor( Handle map, FunctionMode function_mode) { int size = IsFunctionModeWithPrototype(function_mode) ? 5 : 4; Map::EnsureDescriptorSlack(map, size); PropertyAttributes attribs = static_cast( DONT_ENUM | DONT_DELETE | READ_ONLY); Handle length = Accessors::FunctionLengthInfo(isolate(), attribs); { // Add length. CallbacksDescriptor d(Handle(Name::cast(length->name())), length, attribs); map->AppendDescriptor(&d); } Handle name = Accessors::FunctionNameInfo(isolate(), attribs); { // Add name. CallbacksDescriptor d(Handle(Name::cast(name->name())), name, attribs); map->AppendDescriptor(&d); } Handle args = Accessors::FunctionArgumentsInfo(isolate(), attribs); { // Add arguments. CallbacksDescriptor d(Handle(Name::cast(args->name())), args, attribs); map->AppendDescriptor(&d); } Handle caller = Accessors::FunctionCallerInfo(isolate(), attribs); { // Add caller. CallbacksDescriptor d(Handle(Name::cast(caller->name())), caller, attribs); map->AppendDescriptor(&d); } if (IsFunctionModeWithPrototype(function_mode)) { if (function_mode == FUNCTION_WITH_WRITEABLE_PROTOTYPE) { attribs = static_cast(attribs & ~READ_ONLY); } Handle prototype = Accessors::FunctionPrototypeInfo(isolate(), attribs); CallbacksDescriptor d(Handle(Name::cast(prototype->name())), prototype, attribs); map->AppendDescriptor(&d); } } Handle Genesis::CreateFunctionMap(FunctionMode function_mode) { Handle map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); SetFunctionInstanceDescriptor(map, function_mode); map->set_function_with_prototype(IsFunctionModeWithPrototype(function_mode)); 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(FUNCTION_WITHOUT_PROTOTYPE); native_context()->set_sloppy_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(FUNCTION_WITH_READONLY_PROTOTYPE); native_context()->set_sloppy_function_map(*function_map); native_context()->set_sloppy_function_with_readonly_prototype_map( *function_map); // The final map for functions. Writeable prototype. // This map is installed in MakeFunctionInstancePrototypeWritable. sloppy_function_map_writable_prototype_ = CreateFunctionMap(FUNCTION_WITH_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); 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); object_function_map->set_unused_property_fields( JSObject::kInitialGlobalObjectUnusedPropertiesCount); 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 code(isolate->builtins()->builtin(Builtins::kEmptyFunction)); Handle empty_function = factory->NewFunctionWithoutPrototype( empty_string, code); // --- E m p t y --- Handle source = factory->NewStringFromStaticAscii("() {}"); Handle 登录后可以享受更多权益 您还没有登录,登录后您可以: 收藏Android系统代码 收藏喜欢的文章 多个平台共享账号 去登录 首次使用?从这里 注册
(isolate->builtins()->builtin(call)); Handle prototype; Handle function = maybe_prototype.ToHandle(&prototype) ? factory->NewFunction(internalized_name, call_code, prototype, type, instance_size) : factory->NewFunctionWithoutPrototype(internalized_name, call_code); PropertyAttributes attributes; if (target->IsJSBuiltinsObject()) { attributes = static_cast(DONT_ENUM | DONT_DELETE | READ_ONLY); } else { attributes = DONT_ENUM; } JSObject::SetOwnPropertyIgnoreAttributes( target, internalized_name, function, attributes).Check(); if (target->IsJSGlobalObject()) { function->shared()->set_instance_class_name(*internalized_name); } function->shared()->set_native(true); return function; } void Genesis::SetFunctionInstanceDescriptor( Handle map, FunctionMode function_mode) { int size = IsFunctionModeWithPrototype(function_mode) ? 5 : 4; Map::EnsureDescriptorSlack(map, size); PropertyAttributes attribs = static_cast( DONT_ENUM | DONT_DELETE | READ_ONLY); Handle length = Accessors::FunctionLengthInfo(isolate(), attribs); { // Add length. CallbacksDescriptor d(Handle(Name::cast(length->name())), length, attribs); map->AppendDescriptor(&d); } Handle name = Accessors::FunctionNameInfo(isolate(), attribs); { // Add name. CallbacksDescriptor d(Handle(Name::cast(name->name())), name, attribs); map->AppendDescriptor(&d); } Handle args = Accessors::FunctionArgumentsInfo(isolate(), attribs); { // Add arguments. CallbacksDescriptor d(Handle(Name::cast(args->name())), args, attribs); map->AppendDescriptor(&d); } Handle caller = Accessors::FunctionCallerInfo(isolate(), attribs); { // Add caller. CallbacksDescriptor d(Handle(Name::cast(caller->name())), caller, attribs); map->AppendDescriptor(&d); } if (IsFunctionModeWithPrototype(function_mode)) { if (function_mode == FUNCTION_WITH_WRITEABLE_PROTOTYPE) { attribs = static_cast(attribs & ~READ_ONLY); } Handle prototype = Accessors::FunctionPrototypeInfo(isolate(), attribs); CallbacksDescriptor d(Handle(Name::cast(prototype->name())), prototype, attribs); map->AppendDescriptor(&d); } } Handle Genesis::CreateFunctionMap(FunctionMode function_mode) { Handle map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); SetFunctionInstanceDescriptor(map, function_mode); map->set_function_with_prototype(IsFunctionModeWithPrototype(function_mode)); 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(FUNCTION_WITHOUT_PROTOTYPE); native_context()->set_sloppy_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(FUNCTION_WITH_READONLY_PROTOTYPE); native_context()->set_sloppy_function_map(*function_map); native_context()->set_sloppy_function_with_readonly_prototype_map( *function_map); // The final map for functions. Writeable prototype. // This map is installed in MakeFunctionInstancePrototypeWritable. sloppy_function_map_writable_prototype_ = CreateFunctionMap(FUNCTION_WITH_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); 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); object_function_map->set_unused_property_fields( JSObject::kInitialGlobalObjectUnusedPropertiesCount); 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 code(isolate->builtins()->builtin(Builtins::kEmptyFunction)); Handle empty_function = factory->NewFunctionWithoutPrototype( empty_string, code); // --- E m p t y --- Handle source = factory->NewStringFromStaticAscii("() {}"); Handle 登录后可以享受更多权益 您还没有登录,登录后您可以: 收藏Android系统代码 收藏喜欢的文章 多个平台共享账号 去登录 首次使用?从这里 注册
code(isolate->builtins()->builtin(Builtins::kEmptyFunction)); Handle empty_function = factory->NewFunctionWithoutPrototype( empty_string, code); // --- E m p t y --- Handle source = factory->NewStringFromStaticAscii("() {}"); Handle 登录后可以享受更多权益 您还没有登录,登录后您可以: 收藏Android系统代码 收藏喜欢的文章 多个平台共享账号 去登录 首次使用?从这里 注册
您还没有登录,登录后您可以:
首次使用?从这里 注册