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); SetLocalPropertyNoThrow(target, symbol, function, DONT_ENUM); if (is_ecma_native) { function->shared()->set_instance_class_name(*symbol); } return function; } Handle Genesis::ComputeFunctionInstanceDescriptor( PrototypePropertyMode prototypeMode) { Factory* factory = Isolate::Current()->factory(); Handle descriptors = factory->NewDescriptorArray(prototypeMode == DONT_ADD_PROTOTYPE ? 4 : 5); PropertyAttributes attributes = static_cast(DONT_ENUM | DONT_DELETE | READ_ONLY); { // Add length. Handle proxy = factory->NewProxy(&Accessors::FunctionLength); CallbacksDescriptor d(*factory->length_symbol(), *proxy, attributes); descriptors->Set(0, &d); } { // Add name. Handle proxy = factory->NewProxy(&Accessors::FunctionName); CallbacksDescriptor d(*factory->name_symbol(), *proxy, attributes); descriptors->Set(1, &d); } { // Add arguments. Handle proxy = factory->NewProxy(&Accessors::FunctionArguments); CallbacksDescriptor d(*factory->arguments_symbol(), *proxy, attributes); descriptors->Set(2, &d); } { // Add caller. Handle proxy = factory->NewProxy(&Accessors::FunctionCaller); CallbacksDescriptor d(*factory->caller_symbol(), *proxy, attributes); descriptors->Set(3, &d); } if (prototypeMode != DONT_ADD_PROTOTYPE) { // Add prototype. if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) { attributes = static_cast(attributes & ~READ_ONLY); } Handle proxy = factory->NewProxy(&Accessors::FunctionPrototype); CallbacksDescriptor d(*factory->prototype_symbol(), *proxy, attributes); descriptors->Set(4, &d); } descriptors->Sort(); 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() { // 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); Isolate* isolate = Isolate::Current(); 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, kNonStrictMode); // --- 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); SetLocalPropertyNoThrow(target, symbol, function, DONT_ENUM); if (is_ecma_native) { function->shared()->set_instance_class_name(*symbol); } return function; } Handle Genesis::ComputeFunctionInstanceDescriptor( PrototypePropertyMode prototypeMode) { Factory* factory = Isolate::Current()->factory(); Handle descriptors = factory->NewDescriptorArray(prototypeMode == DONT_ADD_PROTOTYPE ? 4 : 5); PropertyAttributes attributes = static_cast(DONT_ENUM | DONT_DELETE | READ_ONLY); { // Add length. Handle proxy = factory->NewProxy(&Accessors::FunctionLength); CallbacksDescriptor d(*factory->length_symbol(), *proxy, attributes); descriptors->Set(0, &d); } { // Add name. Handle proxy = factory->NewProxy(&Accessors::FunctionName); CallbacksDescriptor d(*factory->name_symbol(), *proxy, attributes); descriptors->Set(1, &d); } { // Add arguments. Handle proxy = factory->NewProxy(&Accessors::FunctionArguments); CallbacksDescriptor d(*factory->arguments_symbol(), *proxy, attributes); descriptors->Set(2, &d); } { // Add caller. Handle proxy = factory->NewProxy(&Accessors::FunctionCaller); CallbacksDescriptor d(*factory->caller_symbol(), *proxy, attributes); descriptors->Set(3, &d); } if (prototypeMode != DONT_ADD_PROTOTYPE) { // Add prototype. if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) { attributes = static_cast(attributes & ~READ_ONLY); } Handle proxy = factory->NewProxy(&Accessors::FunctionPrototype); CallbacksDescriptor d(*factory->prototype_symbol(), *proxy, attributes); descriptors->Set(4, &d); } descriptors->Sort(); 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() { // 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); Isolate* isolate = Isolate::Current(); 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, kNonStrictMode); // --- 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系统代码 收藏喜欢的文章 多个平台共享账号 去登录 首次使用?从这里 注册
您还没有登录,登录后您可以:
首次使用?从这里 注册