OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "bootstrapper.h" | 5 #include "bootstrapper.h" |
6 | 6 |
7 #include "accessors.h" | 7 #include "accessors.h" |
8 #include "isolate-inl.h" | 8 #include "isolate-inl.h" |
9 #include "natives.h" | 9 #include "natives.h" |
10 #include "snapshot.h" | 10 #include "snapshot.h" |
(...skipping 2003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2014 ASSERT(!property_string.is_null()); | 2014 ASSERT(!property_string.is_null()); |
2015 Handle<JSFunction> function = Handle<JSFunction>::cast( | 2015 Handle<JSFunction> function = Handle<JSFunction>::cast( |
2016 Object::GetProperty(global, property_string).ToHandleChecked()); | 2016 Object::GetProperty(global, property_string).ToHandleChecked()); |
2017 return Handle<JSObject>(JSObject::cast(function->prototype())); | 2017 return Handle<JSObject>(JSObject::cast(function->prototype())); |
2018 } | 2018 } |
2019 | 2019 |
2020 | 2020 |
2021 static void InstallBuiltinFunctionId(Handle<JSObject> holder, | 2021 static void InstallBuiltinFunctionId(Handle<JSObject> holder, |
2022 const char* function_name, | 2022 const char* function_name, |
2023 BuiltinFunctionId id) { | 2023 BuiltinFunctionId id) { |
2024 Factory* factory = holder->GetIsolate()->factory(); | 2024 Isolate* isolate = holder->GetIsolate(); |
2025 Handle<String> name = factory->InternalizeUtf8String(function_name); | |
2026 Handle<Object> function_object = | 2025 Handle<Object> function_object = |
2027 Object::GetProperty(holder, name).ToHandleChecked(); | 2026 Object::GetProperty(isolate, holder, function_name).ToHandleChecked(); |
2028 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); | 2027 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); |
2029 function->shared()->set_function_data(Smi::FromInt(id)); | 2028 function->shared()->set_function_data(Smi::FromInt(id)); |
2030 } | 2029 } |
2031 | 2030 |
2032 | 2031 |
2033 void Genesis::InstallBuiltinFunctionIds() { | 2032 void Genesis::InstallBuiltinFunctionIds() { |
2034 HandleScope scope(isolate()); | 2033 HandleScope scope(isolate()); |
2035 #define INSTALL_BUILTIN_ID(holder_expr, fun_name, name) \ | 2034 #define INSTALL_BUILTIN_ID(holder_expr, fun_name, name) \ |
2036 { \ | 2035 { \ |
2037 Handle<JSObject> holder = ResolveBuiltinIdHolder( \ | 2036 Handle<JSObject> holder = ResolveBuiltinIdHolder( \ |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2124 if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) { | 2123 if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) { |
2125 Handle<String> natives = | 2124 Handle<String> natives = |
2126 factory->InternalizeUtf8String(FLAG_expose_natives_as); | 2125 factory->InternalizeUtf8String(FLAG_expose_natives_as); |
2127 RETURN_ON_EXCEPTION_VALUE( | 2126 RETURN_ON_EXCEPTION_VALUE( |
2128 isolate, | 2127 isolate, |
2129 JSObject::SetLocalPropertyIgnoreAttributes( | 2128 JSObject::SetLocalPropertyIgnoreAttributes( |
2130 global, natives, Handle<JSObject>(global->builtins()), DONT_ENUM), | 2129 global, natives, Handle<JSObject>(global->builtins()), DONT_ENUM), |
2131 false); | 2130 false); |
2132 } | 2131 } |
2133 | 2132 |
2134 Handle<Object> Error = GetProperty(global, "Error").ToHandleChecked(); | 2133 Handle<Object> Error = Object::GetProperty( |
| 2134 isolate, global, "Error").ToHandleChecked(); |
2135 if (Error->IsJSObject()) { | 2135 if (Error->IsJSObject()) { |
2136 Handle<String> name = factory->InternalizeOneByteString( | 2136 Handle<String> name = factory->InternalizeOneByteString( |
2137 STATIC_ASCII_VECTOR("stackTraceLimit")); | 2137 STATIC_ASCII_VECTOR("stackTraceLimit")); |
2138 Handle<Smi> stack_trace_limit( | 2138 Handle<Smi> stack_trace_limit( |
2139 Smi::FromInt(FLAG_stack_trace_limit), isolate); | 2139 Smi::FromInt(FLAG_stack_trace_limit), isolate); |
2140 RETURN_ON_EXCEPTION_VALUE( | 2140 RETURN_ON_EXCEPTION_VALUE( |
2141 isolate, | 2141 isolate, |
2142 JSObject::SetLocalPropertyIgnoreAttributes( | 2142 JSObject::SetLocalPropertyIgnoreAttributes( |
2143 Handle<JSObject>::cast(Error), name, stack_trace_limit, NONE), | 2143 Handle<JSObject>::cast(Error), name, stack_trace_limit, NONE), |
2144 false); | 2144 false); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2305 extension_states->set_state(current, INSTALLED); | 2305 extension_states->set_state(current, INSTALLED); |
2306 isolate->NotifyExtensionInstalled(); | 2306 isolate->NotifyExtensionInstalled(); |
2307 return result; | 2307 return result; |
2308 } | 2308 } |
2309 | 2309 |
2310 | 2310 |
2311 bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) { | 2311 bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) { |
2312 HandleScope scope(isolate()); | 2312 HandleScope scope(isolate()); |
2313 for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) { | 2313 for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) { |
2314 Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i); | 2314 Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i); |
2315 Handle<String> name = | 2315 Handle<Object> function_object = Object::GetProperty( |
2316 factory()->InternalizeUtf8String(Builtins::GetName(id)); | 2316 isolate(), builtins, Builtins::GetName(id)).ToHandleChecked(); |
2317 Handle<Object> function_object = | |
2318 Object::GetProperty(builtins, name).ToHandleChecked(); | |
2319 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); | 2317 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); |
2320 builtins->set_javascript_builtin(id, *function); | 2318 builtins->set_javascript_builtin(id, *function); |
2321 if (!Compiler::EnsureCompiled(function, CLEAR_EXCEPTION)) { | 2319 if (!Compiler::EnsureCompiled(function, CLEAR_EXCEPTION)) { |
2322 return false; | 2320 return false; |
2323 } | 2321 } |
2324 builtins->set_javascript_builtin_code(id, function->shared()->code()); | 2322 builtins->set_javascript_builtin_code(id, function->shared()->code()); |
2325 } | 2323 } |
2326 return true; | 2324 return true; |
2327 } | 2325 } |
2328 | 2326 |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2682 return from + sizeof(NestingCounterType); | 2680 return from + sizeof(NestingCounterType); |
2683 } | 2681 } |
2684 | 2682 |
2685 | 2683 |
2686 // Called when the top-level V8 mutex is destroyed. | 2684 // Called when the top-level V8 mutex is destroyed. |
2687 void Bootstrapper::FreeThreadResources() { | 2685 void Bootstrapper::FreeThreadResources() { |
2688 ASSERT(!IsActive()); | 2686 ASSERT(!IsActive()); |
2689 } | 2687 } |
2690 | 2688 |
2691 } } // namespace v8::internal | 2689 } } // namespace v8::internal |
OLD | NEW |