call_code = Handle(isolate->builtins()->builtin(call)); Handle function = prototype.is_null() ? factory->NewFunctionWithoutPrototype(symbol, call_code) : factory->NewFunctionWithPrototype(symbol, type, instance_size, prototype, call_code, is_ecma_native); 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, symbol, function, attributes)); if (is_ecma_native) { function->shared()->set_instance_class_name(*symbol); } function->shared()->set_native(true); return function; } Handle Genesis::ComputeFunctionInstanceDescriptor( PrototypePropertyMode prototypeMode) { int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5; Handle descriptors(factory()->NewDescriptorArray(size)); PropertyAttributes attribs = static_cast( DONT_ENUM | DONT_DELETE | READ_ONLY); DescriptorArray::WhitenessWitness witness(*descriptors); { // Add length. Handle f(factory()->NewForeign(&Accessors::FunctionLength)); CallbacksDescriptor d(*factory()->length_symbol(), *f, attribs); descriptors->Set(0, &d, witness); } { // Add name. Handle f(factory()->NewForeign(&Accessors::FunctionName)); CallbacksDescriptor d(*factory()->name_symbol(), *f, attribs); descriptors->Set(1, &d, witness); } { // Add arguments. Handle f(factory()->NewForeign(&Accessors::FunctionArguments)); CallbacksDescriptor d(*factory()->arguments_symbol(), *f, attribs); descriptors->Set(2, &d, witness); } { // Add caller. Handle f(factory()->NewForeign(&Accessors::FunctionCaller)); CallbacksDescriptor d(*factory()->caller_symbol(), *f, attribs); descriptors->Set(3, &d, witness); } if (prototypeMode != DONT_ADD_PROTOTYPE) { // Add prototype. if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) { attribs = static_cast(attribs & ~READ_ONLY); } Handle f(factory()->NewForeign(&Accessors::FunctionPrototype)); CallbacksDescriptor d(*factory()->prototype_symbol(), *f, attribs); descriptors->Set(4, &d, witness); } descriptors->Sort(witness); return descriptors; } Handle Genesis::CreateFunctionMap(PrototypePropertyMode prototype_mode) { Handle map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); Handle descriptors = ComputeFunctionInstanceDescriptor(prototype_mode); map->set_instance_descriptors(*descriptors); 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. // Please note that the prototype property for function instances must be // writable. Handle function_instance_map = CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE); global_context()->set_function_instance_map(*function_instance_map); // 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); global_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); global_context()->set_function_map(*function_map); // The final map for functions. Writeable prototype. // This map is installed in MakeFunctionInstancePrototypeWritable. function_instance_map_writable_prototype_ = CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE); Factory* factory = isolate->factory(); Heap* heap = isolate->heap(); Handle object_name = Handle(heap->Object_symbol()); { // --- 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); global_context()->set_object_function(*object_fun); // Allocate a new prototype for the object function. Handle prototype = factory->NewJSObject( isolate->object_function(), TENURED); global_context()->set_initial_object_prototype(*prototype); SetPrototype(object_fun, prototype); object_function_map-> set_instance_descriptors(heap->empty_descriptor_array()); } // Allocate the empty function as the prototype for function ECMAScript // 262 15.3.4. Handle symbol = factory->LookupAsciiSymbol("Empty"); Handle empty_function = factory->NewFunctionWithoutPrototype(symbol, 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->NewStringFromAscii(CStrVector("() {}")); Handle 登录后可以享受更多权益 您还没有登录,登录后您可以: 收藏Android系统代码 收藏喜欢的文章 多个平台共享账号 去登录 首次使用?从这里 注册
(isolate->builtins()->builtin(call)); Handle function = prototype.is_null() ? factory->NewFunctionWithoutPrototype(symbol, call_code) : factory->NewFunctionWithPrototype(symbol, type, instance_size, prototype, call_code, is_ecma_native); 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, symbol, function, attributes)); if (is_ecma_native) { function->shared()->set_instance_class_name(*symbol); } function->shared()->set_native(true); return function; } Handle Genesis::ComputeFunctionInstanceDescriptor( PrototypePropertyMode prototypeMode) { int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5; Handle descriptors(factory()->NewDescriptorArray(size)); PropertyAttributes attribs = static_cast( DONT_ENUM | DONT_DELETE | READ_ONLY); DescriptorArray::WhitenessWitness witness(*descriptors); { // Add length. Handle f(factory()->NewForeign(&Accessors::FunctionLength)); CallbacksDescriptor d(*factory()->length_symbol(), *f, attribs); descriptors->Set(0, &d, witness); } { // Add name. Handle f(factory()->NewForeign(&Accessors::FunctionName)); CallbacksDescriptor d(*factory()->name_symbol(), *f, attribs); descriptors->Set(1, &d, witness); } { // Add arguments. Handle f(factory()->NewForeign(&Accessors::FunctionArguments)); CallbacksDescriptor d(*factory()->arguments_symbol(), *f, attribs); descriptors->Set(2, &d, witness); } { // Add caller. Handle f(factory()->NewForeign(&Accessors::FunctionCaller)); CallbacksDescriptor d(*factory()->caller_symbol(), *f, attribs); descriptors->Set(3, &d, witness); } if (prototypeMode != DONT_ADD_PROTOTYPE) { // Add prototype. if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) { attribs = static_cast(attribs & ~READ_ONLY); } Handle f(factory()->NewForeign(&Accessors::FunctionPrototype)); CallbacksDescriptor d(*factory()->prototype_symbol(), *f, attribs); descriptors->Set(4, &d, witness); } descriptors->Sort(witness); return descriptors; } Handle Genesis::CreateFunctionMap(PrototypePropertyMode prototype_mode) { Handle map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); Handle descriptors = ComputeFunctionInstanceDescriptor(prototype_mode); map->set_instance_descriptors(*descriptors); 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. // Please note that the prototype property for function instances must be // writable. Handle function_instance_map = CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE); global_context()->set_function_instance_map(*function_instance_map); // 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); global_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); global_context()->set_function_map(*function_map); // The final map for functions. Writeable prototype. // This map is installed in MakeFunctionInstancePrototypeWritable. function_instance_map_writable_prototype_ = CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE); Factory* factory = isolate->factory(); Heap* heap = isolate->heap(); Handle object_name = Handle(heap->Object_symbol()); { // --- 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); global_context()->set_object_function(*object_fun); // Allocate a new prototype for the object function. Handle prototype = factory->NewJSObject( isolate->object_function(), TENURED); global_context()->set_initial_object_prototype(*prototype); SetPrototype(object_fun, prototype); object_function_map-> set_instance_descriptors(heap->empty_descriptor_array()); } // Allocate the empty function as the prototype for function ECMAScript // 262 15.3.4. Handle symbol = factory->LookupAsciiSymbol("Empty"); Handle empty_function = factory->NewFunctionWithoutPrototype(symbol, 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->NewStringFromAscii(CStrVector("() {}")); Handle 登录后可以享受更多权益 您还没有登录,登录后您可以: 收藏Android系统代码 收藏喜欢的文章 多个平台共享账号 去登录 首次使用?从这里 注册
code = Handle(isolate->builtins()->builtin( Builtins::kEmptyFunction)); empty_function->set_code(*code); empty_function->shared()->set_code(*code); Handle source = factory->NewStringFromAscii(CStrVector("() {}")); Handle 登录后可以享受更多权益 您还没有登录,登录后您可以: 收藏Android系统代码 收藏喜欢的文章 多个平台共享账号 去登录 首次使用?从这里 注册
(isolate->builtins()->builtin( Builtins::kEmptyFunction)); empty_function->set_code(*code); empty_function->shared()->set_code(*code); Handle source = factory->NewStringFromAscii(CStrVector("() {}")); Handle 登录后可以享受更多权益 您还没有登录,登录后您可以: 收藏Android系统代码 收藏喜欢的文章 多个平台共享账号 去登录 首次使用?从这里 注册
您还没有登录,登录后您可以:
首次使用?从这里 注册