code); void BuildSpecialFunctionTable(); static bool CompileBuiltin(int index); static bool CompileNative(Vector name, Handle source); static bool CompileScriptCached(Vector name, Handle source, SourceCodeCache* cache, v8::Extension* extension, Handle top_context, bool use_runtime_context); Handle result_; Handle empty_function_; BootstrapperActive active_; friend class Bootstrapper; }; void Bootstrapper::Iterate(ObjectVisitor* v) { extensions_cache.Iterate(v); v->Synchronize("Extensions"); } Handle Bootstrapper::CreateEnvironment( Handle global_object, v8::Handle global_template, v8::ExtensionConfiguration* extensions) { HandleScope scope; Handle env; Genesis genesis(global_object, global_template, extensions); env = genesis.result(); if (!env.is_null()) { if (InstallExtensions(env, extensions)) { return env; } } return Handle(); } static void SetObjectPrototype(Handle object, Handle proto) { // object.__proto__ = proto; Handle old_to_map = Handle(object->map()); Handle new_to_map = Factory::CopyMapDropTransitions(old_to_map); new_to_map->set_prototype(*proto); object->set_map(*new_to_map); } void Bootstrapper::DetachGlobal(Handle env) { JSGlobalProxy::cast(env->global_proxy())->set_context(*Factory::null_value()); SetObjectPrototype(Handle(env->global_proxy()), Factory::null_value()); env->set_global_proxy(env->global()); env->global()->set_global_receiver(env->global()); } void Bootstrapper::ReattachGlobal(Handle env, Handle global_object) { ASSERT(global_object->IsJSGlobalProxy()); Handle global = Handle::cast(global_object); env->global()->set_global_receiver(*global); env->set_global_proxy(*global); SetObjectPrototype(global, Handle(env->global())); global->set_context(*env); } static Handle InstallFunction(Handle target, const char* name, InstanceType type, int instance_size, Handle prototype, Builtins::Name call, bool is_ecma_native) { Handle symbol = Factory::LookupAsciiSymbol(name); Handle call_code = Handle(Builtins::builtin(call)); Handle function = Factory::NewFunctionWithPrototype(symbol, type, instance_size, prototype, call_code, is_ecma_native); SetProperty(target, symbol, function, DONT_ENUM); if (is_ecma_native) { function->shared()->set_instance_class_name(*symbol); } return function; } Handle Genesis::ComputeFunctionInstanceDescriptor( bool make_prototype_read_only, bool make_prototype_enumerable) { Handle result = Factory::empty_descriptor_array(); // Add prototype. PropertyAttributes attributes = static_cast( (make_prototype_enumerable ? 0 : DONT_ENUM) | DONT_DELETE | (make_prototype_read_only ? READ_ONLY : 0)); result = Factory::CopyAppendProxyDescriptor( result, Factory::prototype_symbol(), Factory::NewProxy(&Accessors::FunctionPrototype), attributes); attributes = static_cast(DONT_ENUM | DONT_DELETE | READ_ONLY); // Add length. result = Factory::CopyAppendProxyDescriptor( result, Factory::length_symbol(), Factory::NewProxy(&Accessors::FunctionLength), attributes); // Add name. result = Factory::CopyAppendProxyDescriptor( result, Factory::name_symbol(), Factory::NewProxy(&Accessors::FunctionName), attributes); // Add arguments. result = Factory::CopyAppendProxyDescriptor( result, Factory::arguments_symbol(), Factory::NewProxy(&Accessors::FunctionArguments), attributes); // Add caller. result = Factory::CopyAppendProxyDescriptor( result, Factory::caller_symbol(), Factory::NewProxy(&Accessors::FunctionCaller), attributes); return result; } Handle Genesis::CreateEmptyFunction() { // Allocate the map for function instances. Handle fm = Factory::NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); global_context()->set_function_instance_map(*fm); // Please note that the prototype property for function instances must be // writable. Handle function_map_descriptors = ComputeFunctionInstanceDescriptor(false, false); fm->set_instance_descriptors(*function_map_descriptors); // Allocate the function map first and then patch the prototype later fm = Factory::NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); global_context()->set_function_map(*fm); function_map_descriptors = ComputeFunctionInstanceDescriptor(true); fm->set_instance_descriptors(*function_map_descriptors); 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(Top::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::NewFunction(symbol, Factory::null_value()); // --- E m p t y --- Handle code = Handle(Builtins::builtin(Builtins::EmptyFunction)); empty_function->set_code(*code); Handle source = Factory::NewStringFromAscii(CStrVector("() {}")); Handle 登录后可以享受更多权益 您还没有登录,登录后您可以: 收藏Android系统代码 收藏喜欢的文章 多个平台共享账号 去登录 首次使用?从这里 注册
call_code = Handle(Builtins::builtin(call)); Handle function = Factory::NewFunctionWithPrototype(symbol, type, instance_size, prototype, call_code, is_ecma_native); SetProperty(target, symbol, function, DONT_ENUM); if (is_ecma_native) { function->shared()->set_instance_class_name(*symbol); } return function; } Handle Genesis::ComputeFunctionInstanceDescriptor( bool make_prototype_read_only, bool make_prototype_enumerable) { Handle result = Factory::empty_descriptor_array(); // Add prototype. PropertyAttributes attributes = static_cast( (make_prototype_enumerable ? 0 : DONT_ENUM) | DONT_DELETE | (make_prototype_read_only ? READ_ONLY : 0)); result = Factory::CopyAppendProxyDescriptor( result, Factory::prototype_symbol(), Factory::NewProxy(&Accessors::FunctionPrototype), attributes); attributes = static_cast(DONT_ENUM | DONT_DELETE | READ_ONLY); // Add length. result = Factory::CopyAppendProxyDescriptor( result, Factory::length_symbol(), Factory::NewProxy(&Accessors::FunctionLength), attributes); // Add name. result = Factory::CopyAppendProxyDescriptor( result, Factory::name_symbol(), Factory::NewProxy(&Accessors::FunctionName), attributes); // Add arguments. result = Factory::CopyAppendProxyDescriptor( result, Factory::arguments_symbol(), Factory::NewProxy(&Accessors::FunctionArguments), attributes); // Add caller. result = Factory::CopyAppendProxyDescriptor( result, Factory::caller_symbol(), Factory::NewProxy(&Accessors::FunctionCaller), attributes); return result; } Handle Genesis::CreateEmptyFunction() { // Allocate the map for function instances. Handle fm = Factory::NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); global_context()->set_function_instance_map(*fm); // Please note that the prototype property for function instances must be // writable. Handle function_map_descriptors = ComputeFunctionInstanceDescriptor(false, false); fm->set_instance_descriptors(*function_map_descriptors); // Allocate the function map first and then patch the prototype later fm = Factory::NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); global_context()->set_function_map(*fm); function_map_descriptors = ComputeFunctionInstanceDescriptor(true); fm->set_instance_descriptors(*function_map_descriptors); 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(Top::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::NewFunction(symbol, Factory::null_value()); // --- E m p t y --- Handle code = Handle(Builtins::builtin(Builtins::EmptyFunction)); empty_function->set_code(*code); Handle source = Factory::NewStringFromAscii(CStrVector("() {}")); Handle 登录后可以享受更多权益 您还没有登录,登录后您可以: 收藏Android系统代码 收藏喜欢的文章 多个平台共享账号 去登录 首次使用?从这里 注册
(Builtins::builtin(call)); Handle function = Factory::NewFunctionWithPrototype(symbol, type, instance_size, prototype, call_code, is_ecma_native); SetProperty(target, symbol, function, DONT_ENUM); if (is_ecma_native) { function->shared()->set_instance_class_name(*symbol); } return function; } Handle Genesis::ComputeFunctionInstanceDescriptor( bool make_prototype_read_only, bool make_prototype_enumerable) { Handle result = Factory::empty_descriptor_array(); // Add prototype. PropertyAttributes attributes = static_cast( (make_prototype_enumerable ? 0 : DONT_ENUM) | DONT_DELETE | (make_prototype_read_only ? READ_ONLY : 0)); result = Factory::CopyAppendProxyDescriptor( result, Factory::prototype_symbol(), Factory::NewProxy(&Accessors::FunctionPrototype), attributes); attributes = static_cast(DONT_ENUM | DONT_DELETE | READ_ONLY); // Add length. result = Factory::CopyAppendProxyDescriptor( result, Factory::length_symbol(), Factory::NewProxy(&Accessors::FunctionLength), attributes); // Add name. result = Factory::CopyAppendProxyDescriptor( result, Factory::name_symbol(), Factory::NewProxy(&Accessors::FunctionName), attributes); // Add arguments. result = Factory::CopyAppendProxyDescriptor( result, Factory::arguments_symbol(), Factory::NewProxy(&Accessors::FunctionArguments), attributes); // Add caller. result = Factory::CopyAppendProxyDescriptor( result, Factory::caller_symbol(), Factory::NewProxy(&Accessors::FunctionCaller), attributes); return result; } Handle Genesis::CreateEmptyFunction() { // Allocate the map for function instances. Handle fm = Factory::NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); global_context()->set_function_instance_map(*fm); // Please note that the prototype property for function instances must be // writable. Handle function_map_descriptors = ComputeFunctionInstanceDescriptor(false, false); fm->set_instance_descriptors(*function_map_descriptors); // Allocate the function map first and then patch the prototype later fm = Factory::NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); global_context()->set_function_map(*fm); function_map_descriptors = ComputeFunctionInstanceDescriptor(true); fm->set_instance_descriptors(*function_map_descriptors); 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(Top::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::NewFunction(symbol, Factory::null_value()); // --- E m p t y --- Handle code = Handle(Builtins::builtin(Builtins::EmptyFunction)); empty_function->set_code(*code); Handle source = Factory::NewStringFromAscii(CStrVector("() {}")); Handle 登录后可以享受更多权益 您还没有登录,登录后您可以: 收藏Android系统代码 收藏喜欢的文章 多个平台共享账号 去登录 首次使用?从这里 注册
code = Handle(Builtins::builtin(Builtins::EmptyFunction)); empty_function->set_code(*code); Handle source = Factory::NewStringFromAscii(CStrVector("() {}")); Handle 登录后可以享受更多权益 您还没有登录,登录后您可以: 收藏Android系统代码 收藏喜欢的文章 多个平台共享账号 去登录 首次使用?从这里 注册
(Builtins::builtin(Builtins::EmptyFunction)); empty_function->set_code(*code); Handle source = Factory::NewStringFromAscii(CStrVector("() {}")); Handle 登录后可以享受更多权益 您还没有登录,登录后您可以: 收藏Android系统代码 收藏喜欢的文章 多个平台共享账号 去登录 首次使用?从这里 注册
您还没有登录,登录后您可以:
首次使用?从这里 注册