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 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1508 ? top_context->builtins() | 1508 ? top_context->builtins() |
1509 : top_context->global_object(), | 1509 : top_context->global_object(), |
1510 isolate); | 1510 isolate); |
1511 bool has_pending_exception; | 1511 bool has_pending_exception; |
1512 Execution::Call(isolate, fun, receiver, 0, NULL, &has_pending_exception); | 1512 Execution::Call(isolate, fun, receiver, 0, NULL, &has_pending_exception); |
1513 if (has_pending_exception) return false; | 1513 if (has_pending_exception) return false; |
1514 return true; | 1514 return true; |
1515 } | 1515 } |
1516 | 1516 |
1517 | 1517 |
1518 #define INSTALL_NATIVE(Type, name, var) \ | 1518 #define INSTALL_NATIVE(Type, name, var) \ |
1519 Handle<String> var##_name = \ | 1519 Handle<String> var##_name = \ |
1520 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR(name)); \ | 1520 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR(name)); \ |
1521 Object* var##_native = \ | 1521 Handle<Object> var##_native = GlobalObject::GetPropertyNoExceptionThrown( \ |
1522 native_context()->builtins()->GetPropertyNoExceptionThrown( \ | 1522 handle(native_context()->builtins()), var##_name); \ |
1523 *var##_name); \ | 1523 native_context()->set_##var(Type::cast(*var##_native)); |
1524 native_context()->set_##var(Type::cast(var##_native)); | |
1525 | 1524 |
1526 | 1525 |
1527 void Genesis::InstallNativeFunctions() { | 1526 void Genesis::InstallNativeFunctions() { |
1528 HandleScope scope(isolate()); | 1527 HandleScope scope(isolate()); |
1529 INSTALL_NATIVE(JSFunction, "CreateDate", create_date_fun); | 1528 INSTALL_NATIVE(JSFunction, "CreateDate", create_date_fun); |
1530 INSTALL_NATIVE(JSFunction, "ToNumber", to_number_fun); | 1529 INSTALL_NATIVE(JSFunction, "ToNumber", to_number_fun); |
1531 INSTALL_NATIVE(JSFunction, "ToString", to_string_fun); | 1530 INSTALL_NATIVE(JSFunction, "ToString", to_string_fun); |
1532 INSTALL_NATIVE(JSFunction, "ToDetailString", to_detail_string_fun); | 1531 INSTALL_NATIVE(JSFunction, "ToDetailString", to_detail_string_fun); |
1533 INSTALL_NATIVE(JSFunction, "ToObject", to_object_fun); | 1532 INSTALL_NATIVE(JSFunction, "ToObject", to_object_fun); |
1534 INSTALL_NATIVE(JSFunction, "ToInteger", to_integer_fun); | 1533 INSTALL_NATIVE(JSFunction, "ToInteger", to_integer_fun); |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2047 Object::GetProperty(global, property_string)); | 2046 Object::GetProperty(global, property_string)); |
2048 return Handle<JSObject>(JSObject::cast(function->prototype())); | 2047 return Handle<JSObject>(JSObject::cast(function->prototype())); |
2049 } | 2048 } |
2050 | 2049 |
2051 | 2050 |
2052 static void InstallBuiltinFunctionId(Handle<JSObject> holder, | 2051 static void InstallBuiltinFunctionId(Handle<JSObject> holder, |
2053 const char* function_name, | 2052 const char* function_name, |
2054 BuiltinFunctionId id) { | 2053 BuiltinFunctionId id) { |
2055 Factory* factory = holder->GetIsolate()->factory(); | 2054 Factory* factory = holder->GetIsolate()->factory(); |
2056 Handle<String> name = factory->InternalizeUtf8String(function_name); | 2055 Handle<String> name = factory->InternalizeUtf8String(function_name); |
2057 Object* function_object = holder->GetProperty(*name)->ToObjectUnchecked(); | 2056 Handle<Object> function_object = Object::GetProperty(holder, name); |
2058 Handle<JSFunction> function(JSFunction::cast(function_object)); | 2057 ASSERT(!function_object.is_null()); |
| 2058 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); |
2059 function->shared()->set_function_data(Smi::FromInt(id)); | 2059 function->shared()->set_function_data(Smi::FromInt(id)); |
2060 } | 2060 } |
2061 | 2061 |
2062 | 2062 |
2063 void Genesis::InstallBuiltinFunctionIds() { | 2063 void Genesis::InstallBuiltinFunctionIds() { |
2064 HandleScope scope(isolate()); | 2064 HandleScope scope(isolate()); |
2065 #define INSTALL_BUILTIN_ID(holder_expr, fun_name, name) \ | 2065 #define INSTALL_BUILTIN_ID(holder_expr, fun_name, name) \ |
2066 { \ | 2066 { \ |
2067 Handle<JSObject> holder = ResolveBuiltinIdHolder( \ | 2067 Handle<JSObject> holder = ResolveBuiltinIdHolder( \ |
2068 native_context(), #holder_expr); \ | 2068 native_context(), #holder_expr); \ |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2342 return result; | 2342 return result; |
2343 } | 2343 } |
2344 | 2344 |
2345 | 2345 |
2346 bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) { | 2346 bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) { |
2347 HandleScope scope(isolate()); | 2347 HandleScope scope(isolate()); |
2348 for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) { | 2348 for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) { |
2349 Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i); | 2349 Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i); |
2350 Handle<String> name = | 2350 Handle<String> name = |
2351 factory()->InternalizeUtf8String(Builtins::GetName(id)); | 2351 factory()->InternalizeUtf8String(Builtins::GetName(id)); |
2352 Object* function_object = builtins->GetPropertyNoExceptionThrown(*name); | 2352 Handle<Object> function_object = |
2353 Handle<JSFunction> function | 2353 GlobalObject::GetPropertyNoExceptionThrown(builtins, name); |
2354 = Handle<JSFunction>(JSFunction::cast(function_object)); | 2354 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); |
2355 builtins->set_javascript_builtin(id, *function); | 2355 builtins->set_javascript_builtin(id, *function); |
2356 if (!Compiler::EnsureCompiled(function, CLEAR_EXCEPTION)) { | 2356 if (!Compiler::EnsureCompiled(function, CLEAR_EXCEPTION)) { |
2357 return false; | 2357 return false; |
2358 } | 2358 } |
2359 builtins->set_javascript_builtin_code(id, function->shared()->code()); | 2359 builtins->set_javascript_builtin_code(id, function->shared()->code()); |
2360 } | 2360 } |
2361 return true; | 2361 return true; |
2362 } | 2362 } |
2363 | 2363 |
2364 | 2364 |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2717 return from + sizeof(NestingCounterType); | 2717 return from + sizeof(NestingCounterType); |
2718 } | 2718 } |
2719 | 2719 |
2720 | 2720 |
2721 // Called when the top-level V8 mutex is destroyed. | 2721 // Called when the top-level V8 mutex is destroyed. |
2722 void Bootstrapper::FreeThreadResources() { | 2722 void Bootstrapper::FreeThreadResources() { |
2723 ASSERT(!IsActive()); | 2723 ASSERT(!IsActive()); |
2724 } | 2724 } |
2725 | 2725 |
2726 } } // namespace v8::internal | 2726 } } // namespace v8::internal |
OLD | NEW |