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

Side by Side Diff: src/bootstrapper.cc

Issue 895053002: Move the contents of api-natives.js to c++ (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « src/apinatives.js ('k') | src/builtins.cc » ('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/api-natives.h"
8 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
9 #include "src/extensions/externalize-string-extension.h" 10 #include "src/extensions/externalize-string-extension.h"
10 #include "src/extensions/free-buffer-extension.h" 11 #include "src/extensions/free-buffer-extension.h"
11 #include "src/extensions/gc-extension.h" 12 #include "src/extensions/gc-extension.h"
12 #include "src/extensions/statistics-extension.h" 13 #include "src/extensions/statistics-extension.h"
13 #include "src/extensions/trigger-failure-extension.h" 14 #include "src/extensions/trigger-failure-extension.h"
14 #include "src/isolate-inl.h" 15 #include "src/isolate-inl.h"
15 #include "src/natives.h" 16 #include "src/natives.h"
16 #include "src/snapshot.h" 17 #include "src/snapshot.h"
17 #include "third_party/fdlibm/fdlibm.h" 18 #include "third_party/fdlibm/fdlibm.h"
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 #ifdef DEBUG 803 #ifdef DEBUG
803 LookupIterator it(prototype, factory()->constructor_string(), 804 LookupIterator it(prototype, factory()->constructor_string(),
804 LookupIterator::OWN_SKIP_INTERCEPTOR); 805 LookupIterator::OWN_SKIP_INTERCEPTOR);
805 Handle<Object> value = JSReceiver::GetProperty(&it).ToHandleChecked(); 806 Handle<Object> value = JSReceiver::GetProperty(&it).ToHandleChecked();
806 DCHECK(it.IsFound()); 807 DCHECK(it.IsFound());
807 DCHECK_EQ(*isolate()->object_function(), *value); 808 DCHECK_EQ(*isolate()->object_function(), *value);
808 #endif 809 #endif
809 } else { 810 } else {
810 Handle<FunctionTemplateInfo> js_global_object_constructor( 811 Handle<FunctionTemplateInfo> js_global_object_constructor(
811 FunctionTemplateInfo::cast(js_global_object_template->constructor())); 812 FunctionTemplateInfo::cast(js_global_object_template->constructor()));
812 js_global_object_function = 813 js_global_object_function = ApiNatives::CreateApiFunction(
813 factory()->CreateApiFunction(js_global_object_constructor, 814 isolate(), js_global_object_constructor, factory()->the_hole_value(),
814 factory()->the_hole_value(), 815 ApiNatives::GlobalObjectType);
815 factory()->GlobalObjectType);
816 } 816 }
817 817
818 js_global_object_function->initial_map()->set_is_hidden_prototype(); 818 js_global_object_function->initial_map()->set_is_hidden_prototype();
819 js_global_object_function->initial_map()->set_dictionary_map(true); 819 js_global_object_function->initial_map()->set_dictionary_map(true);
820 Handle<GlobalObject> global_object = 820 Handle<GlobalObject> global_object =
821 factory()->NewGlobalObject(js_global_object_function); 821 factory()->NewGlobalObject(js_global_object_function);
822 822
823 // Step 2: (re)initialize the global proxy object. 823 // Step 2: (re)initialize the global proxy object.
824 Handle<JSFunction> global_proxy_function; 824 Handle<JSFunction> global_proxy_function;
825 if (global_proxy_template.IsEmpty()) { 825 if (global_proxy_template.IsEmpty()) {
826 Handle<String> name = Handle<String>(heap()->empty_string()); 826 Handle<String> name = Handle<String>(heap()->empty_string());
827 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin( 827 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin(
828 Builtins::kIllegal)); 828 Builtins::kIllegal));
829 global_proxy_function = factory()->NewFunction( 829 global_proxy_function = factory()->NewFunction(
830 name, code, JS_GLOBAL_PROXY_TYPE, JSGlobalProxy::kSize); 830 name, code, JS_GLOBAL_PROXY_TYPE, JSGlobalProxy::kSize);
831 } else { 831 } else {
832 Handle<ObjectTemplateInfo> data = 832 Handle<ObjectTemplateInfo> data =
833 v8::Utils::OpenHandle(*global_proxy_template); 833 v8::Utils::OpenHandle(*global_proxy_template);
834 Handle<FunctionTemplateInfo> global_constructor( 834 Handle<FunctionTemplateInfo> global_constructor(
835 FunctionTemplateInfo::cast(data->constructor())); 835 FunctionTemplateInfo::cast(data->constructor()));
836 global_proxy_function = 836 global_proxy_function = ApiNatives::CreateApiFunction(
837 factory()->CreateApiFunction(global_constructor, 837 isolate(), global_constructor, factory()->the_hole_value(),
838 factory()->the_hole_value(), 838 ApiNatives::GlobalProxyType);
839 factory()->GlobalProxyType);
840 } 839 }
841 840
842 Handle<String> global_name = factory()->global_string(); 841 Handle<String> global_name = factory()->global_string();
843 global_proxy_function->shared()->set_instance_class_name(*global_name); 842 global_proxy_function->shared()->set_instance_class_name(*global_name);
844 global_proxy_function->initial_map()->set_is_access_check_needed(true); 843 global_proxy_function->initial_map()->set_is_access_check_needed(true);
845 844
846 // Set global_proxy.__proto__ to js_global after ConfigureGlobalObjects 845 // Set global_proxy.__proto__ to js_global after ConfigureGlobalObjects
847 // Return the global proxy. 846 // Return the global proxy.
848 847
849 factory()->ReinitializeJSGlobalProxy(global_proxy, global_proxy_function); 848 factory()->ReinitializeJSGlobalProxy(global_proxy, global_proxy_function);
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
1526 INSTALL_NATIVE(JSFunction, "ToNumber", to_number_fun); 1525 INSTALL_NATIVE(JSFunction, "ToNumber", to_number_fun);
1527 INSTALL_NATIVE(JSFunction, "ToString", to_string_fun); 1526 INSTALL_NATIVE(JSFunction, "ToString", to_string_fun);
1528 INSTALL_NATIVE(JSFunction, "ToDetailString", to_detail_string_fun); 1527 INSTALL_NATIVE(JSFunction, "ToDetailString", to_detail_string_fun);
1529 INSTALL_NATIVE(JSFunction, "ToObject", to_object_fun); 1528 INSTALL_NATIVE(JSFunction, "ToObject", to_object_fun);
1530 INSTALL_NATIVE(JSFunction, "ToInteger", to_integer_fun); 1529 INSTALL_NATIVE(JSFunction, "ToInteger", to_integer_fun);
1531 INSTALL_NATIVE(JSFunction, "ToUint32", to_uint32_fun); 1530 INSTALL_NATIVE(JSFunction, "ToUint32", to_uint32_fun);
1532 INSTALL_NATIVE(JSFunction, "ToInt32", to_int32_fun); 1531 INSTALL_NATIVE(JSFunction, "ToInt32", to_int32_fun);
1533 INSTALL_NATIVE(JSFunction, "ToLength", to_length_fun); 1532 INSTALL_NATIVE(JSFunction, "ToLength", to_length_fun);
1534 1533
1535 INSTALL_NATIVE(JSFunction, "GlobalEval", global_eval_fun); 1534 INSTALL_NATIVE(JSFunction, "GlobalEval", global_eval_fun);
1536 INSTALL_NATIVE(JSFunction, "Instantiate", instantiate_fun);
1537 INSTALL_NATIVE(JSFunction, "ConfigureTemplateInstance",
1538 configure_instance_fun);
1539 INSTALL_NATIVE(JSFunction, "GetStackTraceLine", get_stack_trace_line_fun); 1535 INSTALL_NATIVE(JSFunction, "GetStackTraceLine", get_stack_trace_line_fun);
1540 INSTALL_NATIVE(JSObject, "functionCache", function_cache);
1541 INSTALL_NATIVE(JSFunction, "ToCompletePropertyDescriptor", 1536 INSTALL_NATIVE(JSFunction, "ToCompletePropertyDescriptor",
1542 to_complete_property_descriptor); 1537 to_complete_property_descriptor);
1543 1538
1544 INSTALL_NATIVE(JSFunction, "IsPromise", is_promise); 1539 INSTALL_NATIVE(JSFunction, "IsPromise", is_promise);
1545 INSTALL_NATIVE(JSFunction, "PromiseCreate", promise_create); 1540 INSTALL_NATIVE(JSFunction, "PromiseCreate", promise_create);
1546 INSTALL_NATIVE(JSFunction, "PromiseResolve", promise_resolve); 1541 INSTALL_NATIVE(JSFunction, "PromiseResolve", promise_resolve);
1547 INSTALL_NATIVE(JSFunction, "PromiseReject", promise_reject); 1542 INSTALL_NATIVE(JSFunction, "PromiseReject", promise_reject);
1548 INSTALL_NATIVE(JSFunction, "PromiseChain", promise_chain); 1543 INSTALL_NATIVE(JSFunction, "PromiseChain", promise_chain);
1549 INSTALL_NATIVE(JSFunction, "PromiseCatch", promise_catch); 1544 INSTALL_NATIVE(JSFunction, "PromiseCatch", promise_catch);
1550 INSTALL_NATIVE(JSFunction, "PromiseThen", promise_then); 1545 INSTALL_NATIVE(JSFunction, "PromiseThen", promise_then);
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
2035 i++) { 2030 i++) {
2036 if (!CompileBuiltin(isolate(), i)) return false; 2031 if (!CompileBuiltin(isolate(), i)) return false;
2037 // TODO(ager): We really only need to install the JS builtin 2032 // TODO(ager): We really only need to install the JS builtin
2038 // functions on the builtins object after compiling and running 2033 // functions on the builtins object after compiling and running
2039 // runtime.js. 2034 // runtime.js.
2040 if (!InstallJSBuiltins(builtins)) return false; 2035 if (!InstallJSBuiltins(builtins)) return false;
2041 } 2036 }
2042 2037
2043 InstallNativeFunctions(); 2038 InstallNativeFunctions();
2044 2039
2040 native_context()->set_function_cache(heap()->empty_fixed_array());
2041
2045 // Store the map for the string prototype after the natives has been compiled 2042 // Store the map for the string prototype after the natives has been compiled
2046 // and the String function has been set up. 2043 // and the String function has been set up.
2047 Handle<JSFunction> string_function(native_context()->string_function()); 2044 Handle<JSFunction> string_function(native_context()->string_function());
2048 DCHECK(JSObject::cast( 2045 DCHECK(JSObject::cast(
2049 string_function->initial_map()->prototype())->HasFastProperties()); 2046 string_function->initial_map()->prototype())->HasFastProperties());
2050 native_context()->set_string_function_prototype_map( 2047 native_context()->set_string_function_prototype_map(
2051 HeapObject::cast(string_function->initial_map()->prototype())->map()); 2048 HeapObject::cast(string_function->initial_map()->prototype())->map());
2052 2049
2053 // Install Function.prototype.call and apply. 2050 // Install Function.prototype.call and apply.
2054 { 2051 {
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
2568 } 2565 }
2569 2566
2570 2567
2571 bool Genesis::ConfigureApiObject(Handle<JSObject> object, 2568 bool Genesis::ConfigureApiObject(Handle<JSObject> object,
2572 Handle<ObjectTemplateInfo> object_template) { 2569 Handle<ObjectTemplateInfo> object_template) {
2573 DCHECK(!object_template.is_null()); 2570 DCHECK(!object_template.is_null());
2574 DCHECK(FunctionTemplateInfo::cast(object_template->constructor()) 2571 DCHECK(FunctionTemplateInfo::cast(object_template->constructor())
2575 ->IsTemplateFor(object->map()));; 2572 ->IsTemplateFor(object->map()));;
2576 2573
2577 MaybeHandle<JSObject> maybe_obj = 2574 MaybeHandle<JSObject> maybe_obj =
2578 Execution::InstantiateObject(object_template); 2575 ApiNatives::InstantiateObject(object_template);
2579 Handle<JSObject> obj; 2576 Handle<JSObject> obj;
2580 if (!maybe_obj.ToHandle(&obj)) { 2577 if (!maybe_obj.ToHandle(&obj)) {
2581 DCHECK(isolate()->has_pending_exception()); 2578 DCHECK(isolate()->has_pending_exception());
2582 isolate()->clear_pending_exception(); 2579 isolate()->clear_pending_exception();
2583 return false; 2580 return false;
2584 } 2581 }
2585 TransferObject(obj, object); 2582 TransferObject(obj, object);
2586 return true; 2583 return true;
2587 } 2584 }
2588 2585
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
2879 return from + sizeof(NestingCounterType); 2876 return from + sizeof(NestingCounterType);
2880 } 2877 }
2881 2878
2882 2879
2883 // Called when the top-level V8 mutex is destroyed. 2880 // Called when the top-level V8 mutex is destroyed.
2884 void Bootstrapper::FreeThreadResources() { 2881 void Bootstrapper::FreeThreadResources() {
2885 DCHECK(!IsActive()); 2882 DCHECK(!IsActive());
2886 } 2883 }
2887 2884
2888 } } // namespace v8::internal 2885 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/apinatives.js ('k') | src/builtins.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698