Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1153)

Side by Side Diff: src/bootstrapper.cc

Issue 426233002: Land the Fan (disabled) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback, rebase and "git cl format" Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/base/logging.h ('k') | src/checks.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "src/bootstrapper.h" 5 #include "src/bootstrapper.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/extensions/externalize-string-extension.h" 9 #include "src/extensions/externalize-string-extension.h"
10 #include "src/extensions/free-buffer-extension.h" 10 #include "src/extensions/free-buffer-extension.h"
(...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 Handle<Object> receiver = 1527 Handle<Object> receiver =
1528 Handle<Object>(use_runtime_context 1528 Handle<Object>(use_runtime_context
1529 ? top_context->builtins() 1529 ? top_context->builtins()
1530 : top_context->global_object(), 1530 : top_context->global_object(),
1531 isolate); 1531 isolate);
1532 return !Execution::Call( 1532 return !Execution::Call(
1533 isolate, fun, receiver, 0, NULL).is_null(); 1533 isolate, fun, receiver, 0, NULL).is_null();
1534 } 1534 }
1535 1535
1536 1536
1537 static Handle<JSObject> ResolveBuiltinIdHolder(Handle<Context> native_context,
1538 const char* holder_expr) {
1539 Isolate* isolate = native_context->GetIsolate();
1540 Factory* factory = isolate->factory();
1541 Handle<GlobalObject> global(native_context->global_object());
1542 const char* period_pos = strchr(holder_expr, '.');
1543 if (period_pos == NULL) {
1544 return Handle<JSObject>::cast(
1545 Object::GetPropertyOrElement(
1546 global, factory->InternalizeUtf8String(holder_expr))
1547 .ToHandleChecked());
1548 }
1549 const char* inner = period_pos + 1;
1550 ASSERT_EQ(NULL, strchr(inner, '.'));
1551 Vector<const char> property(holder_expr,
1552 static_cast<int>(period_pos - holder_expr));
1553 Handle<String> property_string = factory->InternalizeUtf8String(property);
1554 ASSERT(!property_string.is_null());
1555 Handle<JSObject> object = Handle<JSObject>::cast(
1556 Object::GetProperty(global, property_string).ToHandleChecked());
1557 if (strcmp("prototype", inner) == 0) {
1558 Handle<JSFunction> function = Handle<JSFunction>::cast(object);
1559 return Handle<JSObject>(JSObject::cast(function->prototype()));
1560 }
1561 Handle<String> inner_string = factory->InternalizeUtf8String(inner);
1562 ASSERT(!inner_string.is_null());
1563 Handle<Object> value =
1564 Object::GetProperty(object, inner_string).ToHandleChecked();
1565 return Handle<JSObject>::cast(value);
1566 }
1567
1568
1537 #define INSTALL_NATIVE(Type, name, var) \ 1569 #define INSTALL_NATIVE(Type, name, var) \
1538 Handle<String> var##_name = \ 1570 Handle<String> var##_name = \
1539 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR(name)); \ 1571 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR(name)); \
1540 Handle<Object> var##_native = Object::GetProperty( \ 1572 Handle<Object> var##_native = Object::GetProperty( \
1541 handle(native_context()->builtins()), var##_name).ToHandleChecked(); \ 1573 handle(native_context()->builtins()), var##_name).ToHandleChecked(); \
1542 native_context()->set_##var(Type::cast(*var##_native)); 1574 native_context()->set_##var(Type::cast(*var##_native));
1543 1575
1576 #define INSTALL_NATIVE_MATH(name) \
1577 { \
1578 Handle<Object> fun = \
1579 ResolveBuiltinIdHolder(native_context(), "Math." #name); \
1580 native_context()->set_math_##name##_fun(JSFunction::cast(*fun)); \
1581 }
1544 1582
1545 void Genesis::InstallNativeFunctions() { 1583 void Genesis::InstallNativeFunctions() {
1546 HandleScope scope(isolate()); 1584 HandleScope scope(isolate());
1547 INSTALL_NATIVE(JSFunction, "CreateDate", create_date_fun); 1585 INSTALL_NATIVE(JSFunction, "CreateDate", create_date_fun);
1548 1586
1549 INSTALL_NATIVE(JSFunction, "ToNumber", to_number_fun); 1587 INSTALL_NATIVE(JSFunction, "ToNumber", to_number_fun);
1550 INSTALL_NATIVE(JSFunction, "ToString", to_string_fun); 1588 INSTALL_NATIVE(JSFunction, "ToString", to_string_fun);
1551 INSTALL_NATIVE(JSFunction, "ToDetailString", to_detail_string_fun); 1589 INSTALL_NATIVE(JSFunction, "ToDetailString", to_detail_string_fun);
1552 INSTALL_NATIVE(JSFunction, "ToObject", to_object_fun); 1590 INSTALL_NATIVE(JSFunction, "ToObject", to_object_fun);
1553 INSTALL_NATIVE(JSFunction, "ToInteger", to_integer_fun); 1591 INSTALL_NATIVE(JSFunction, "ToInteger", to_integer_fun);
(...skipping 22 matching lines...) Expand all
1576 INSTALL_NATIVE(JSFunction, "BeginPerformSplice", 1614 INSTALL_NATIVE(JSFunction, "BeginPerformSplice",
1577 observers_begin_perform_splice); 1615 observers_begin_perform_splice);
1578 INSTALL_NATIVE(JSFunction, "EndPerformSplice", 1616 INSTALL_NATIVE(JSFunction, "EndPerformSplice",
1579 observers_end_perform_splice); 1617 observers_end_perform_splice);
1580 INSTALL_NATIVE(JSFunction, "NativeObjectObserve", 1618 INSTALL_NATIVE(JSFunction, "NativeObjectObserve",
1581 native_object_observe); 1619 native_object_observe);
1582 INSTALL_NATIVE(JSFunction, "NativeObjectGetNotifier", 1620 INSTALL_NATIVE(JSFunction, "NativeObjectGetNotifier",
1583 native_object_get_notifier); 1621 native_object_get_notifier);
1584 INSTALL_NATIVE(JSFunction, "NativeObjectNotifierPerformChange", 1622 INSTALL_NATIVE(JSFunction, "NativeObjectNotifierPerformChange",
1585 native_object_notifier_perform_change); 1623 native_object_notifier_perform_change);
1624
1625 INSTALL_NATIVE_MATH(abs)
1626 INSTALL_NATIVE_MATH(acos)
1627 INSTALL_NATIVE_MATH(asin)
1628 INSTALL_NATIVE_MATH(atan)
1629 INSTALL_NATIVE_MATH(atan2)
1630 INSTALL_NATIVE_MATH(ceil)
1631 INSTALL_NATIVE_MATH(cos)
1632 INSTALL_NATIVE_MATH(exp)
1633 INSTALL_NATIVE_MATH(floor)
1634 INSTALL_NATIVE_MATH(imul)
1635 INSTALL_NATIVE_MATH(log)
1636 INSTALL_NATIVE_MATH(max)
1637 INSTALL_NATIVE_MATH(min)
1638 INSTALL_NATIVE_MATH(pow)
1639 INSTALL_NATIVE_MATH(random)
1640 INSTALL_NATIVE_MATH(round)
1641 INSTALL_NATIVE_MATH(sin)
1642 INSTALL_NATIVE_MATH(sqrt)
1643 INSTALL_NATIVE_MATH(tan)
1586 } 1644 }
1587 1645
1588 1646
1589 void Genesis::InstallExperimentalNativeFunctions() { 1647 void Genesis::InstallExperimentalNativeFunctions() {
1590 if (FLAG_harmony_proxies) { 1648 if (FLAG_harmony_proxies) {
1591 INSTALL_NATIVE(JSFunction, "DerivedHasTrap", derived_has_trap); 1649 INSTALL_NATIVE(JSFunction, "DerivedHasTrap", derived_has_trap);
1592 INSTALL_NATIVE(JSFunction, "DerivedGetTrap", derived_get_trap); 1650 INSTALL_NATIVE(JSFunction, "DerivedGetTrap", derived_get_trap);
1593 INSTALL_NATIVE(JSFunction, "DerivedSetTrap", derived_set_trap); 1651 INSTALL_NATIVE(JSFunction, "DerivedSetTrap", derived_set_trap);
1594 INSTALL_NATIVE(JSFunction, "ProxyEnumerate", proxy_enumerate); 1652 INSTALL_NATIVE(JSFunction, "ProxyEnumerate", proxy_enumerate);
1595 } 1653 }
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
2022 INSTALL_EXPERIMENTAL_NATIVE(i, iteration, "string-iterator.js") 2080 INSTALL_EXPERIMENTAL_NATIVE(i, iteration, "string-iterator.js")
2023 INSTALL_EXPERIMENTAL_NATIVE(i, strings, "harmony-string.js") 2081 INSTALL_EXPERIMENTAL_NATIVE(i, strings, "harmony-string.js")
2024 INSTALL_EXPERIMENTAL_NATIVE(i, arrays, "harmony-array.js") 2082 INSTALL_EXPERIMENTAL_NATIVE(i, arrays, "harmony-array.js")
2025 } 2083 }
2026 2084
2027 InstallExperimentalNativeFunctions(); 2085 InstallExperimentalNativeFunctions();
2028 return true; 2086 return true;
2029 } 2087 }
2030 2088
2031 2089
2032 static Handle<JSObject> ResolveBuiltinIdHolder(
2033 Handle<Context> native_context,
2034 const char* holder_expr) {
2035 Isolate* isolate = native_context->GetIsolate();
2036 Factory* factory = isolate->factory();
2037 Handle<GlobalObject> global(native_context->global_object());
2038 const char* period_pos = strchr(holder_expr, '.');
2039 if (period_pos == NULL) {
2040 return Handle<JSObject>::cast(Object::GetPropertyOrElement(
2041 global, factory->InternalizeUtf8String(holder_expr)).ToHandleChecked());
2042 }
2043 ASSERT_EQ(".prototype", period_pos);
2044 Vector<const char> property(holder_expr,
2045 static_cast<int>(period_pos - holder_expr));
2046 Handle<String> property_string = factory->InternalizeUtf8String(property);
2047 ASSERT(!property_string.is_null());
2048 Handle<JSFunction> function = Handle<JSFunction>::cast(
2049 Object::GetProperty(global, property_string).ToHandleChecked());
2050 return Handle<JSObject>(JSObject::cast(function->prototype()));
2051 }
2052
2053
2054 static void InstallBuiltinFunctionId(Handle<JSObject> holder, 2090 static void InstallBuiltinFunctionId(Handle<JSObject> holder,
2055 const char* function_name, 2091 const char* function_name,
2056 BuiltinFunctionId id) { 2092 BuiltinFunctionId id) {
2057 Isolate* isolate = holder->GetIsolate(); 2093 Isolate* isolate = holder->GetIsolate();
2058 Handle<Object> function_object = 2094 Handle<Object> function_object =
2059 Object::GetProperty(isolate, holder, function_name).ToHandleChecked(); 2095 Object::GetProperty(isolate, holder, function_name).ToHandleChecked();
2060 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); 2096 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
2061 function->shared()->set_function_data(Smi::FromInt(id)); 2097 function->shared()->set_function_data(Smi::FromInt(id));
2062 } 2098 }
2063 2099
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
2329 2365
2330 2366
2331 bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) { 2367 bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) {
2332 HandleScope scope(isolate()); 2368 HandleScope scope(isolate());
2333 for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) { 2369 for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) {
2334 Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i); 2370 Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i);
2335 Handle<Object> function_object = Object::GetProperty( 2371 Handle<Object> function_object = Object::GetProperty(
2336 isolate(), builtins, Builtins::GetName(id)).ToHandleChecked(); 2372 isolate(), builtins, Builtins::GetName(id)).ToHandleChecked();
2337 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); 2373 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
2338 builtins->set_javascript_builtin(id, *function); 2374 builtins->set_javascript_builtin(id, *function);
2375 // TODO(mstarzinger): This is just a temporary hack to make TurboFan work,
2376 // the correct solution is to restore the context register after invoking
2377 // builtins from full-codegen.
2378 function->shared()->set_optimization_disabled(true);
2339 if (!Compiler::EnsureCompiled(function, CLEAR_EXCEPTION)) { 2379 if (!Compiler::EnsureCompiled(function, CLEAR_EXCEPTION)) {
2340 return false; 2380 return false;
2341 } 2381 }
2342 builtins->set_javascript_builtin_code(id, function->shared()->code()); 2382 builtins->set_javascript_builtin_code(id, function->shared()->code());
2343 } 2383 }
2344 return true; 2384 return true;
2345 } 2385 }
2346 2386
2347 2387
2348 bool Genesis::ConfigureGlobalObjects( 2388 bool Genesis::ConfigureGlobalObjects(
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
2693 return from + sizeof(NestingCounterType); 2733 return from + sizeof(NestingCounterType);
2694 } 2734 }
2695 2735
2696 2736
2697 // Called when the top-level V8 mutex is destroyed. 2737 // Called when the top-level V8 mutex is destroyed.
2698 void Bootstrapper::FreeThreadResources() { 2738 void Bootstrapper::FreeThreadResources() {
2699 ASSERT(!IsActive()); 2739 ASSERT(!IsActive());
2700 } 2740 }
2701 2741
2702 } } // namespace v8::internal 2742 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/base/logging.h ('k') | src/checks.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698