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

Side by Side Diff: src/bootstrapper.cc

Issue 2222893002: Move family of MakeError functions to C++ (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix in prologue.js Created 4 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
« no previous file with comments | « no previous file | src/builtins/builtins.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/api-natives.h" 8 #include "src/api-natives.h"
9 #include "src/base/ieee754.h" 9 #include "src/base/ieee754.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 PropertyAttributes attribs = DONT_ENUM; 1035 PropertyAttributes attribs = DONT_ENUM;
1036 Handle<AccessorInfo> error_stack = 1036 Handle<AccessorInfo> error_stack =
1037 Accessors::ErrorStackInfo(isolate, attribs); 1037 Accessors::ErrorStackInfo(isolate, attribs);
1038 { 1038 {
1039 AccessorConstantDescriptor d(Handle<Name>(Name::cast(error_stack->name())), 1039 AccessorConstantDescriptor d(Handle<Name>(Name::cast(error_stack->name())),
1040 error_stack, attribs); 1040 error_stack, attribs);
1041 initial_map->AppendDescriptor(&d); 1041 initial_map->AppendDescriptor(&d);
1042 } 1042 }
1043 } 1043 }
1044 1044
1045 static void InstallMakeError(Isolate* isolate, Handle<Code> code,
1046 int context_index) {
1047 Handle<JSFunction> function =
1048 isolate->factory()->NewFunction(isolate->factory()->empty_string(), code,
1049 JS_OBJECT_TYPE, JSObject::kHeaderSize);
1050 function->shared()->DontAdaptArguments();
1051 isolate->native_context()->set(context_index, *function);
1052 }
1053
1045 // This is only called if we are not using snapshots. The equivalent 1054 // This is only called if we are not using snapshots. The equivalent
1046 // work in the snapshot case is done in HookUpGlobalObject. 1055 // work in the snapshot case is done in HookUpGlobalObject.
1047 void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, 1056 void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
1048 Handle<JSFunction> empty_function, 1057 Handle<JSFunction> empty_function,
1049 GlobalContextType context_type) { 1058 GlobalContextType context_type) {
1050 // --- N a t i v e C o n t e x t --- 1059 // --- N a t i v e C o n t e x t ---
1051 // Use the empty function as closure (no scope info). 1060 // Use the empty function as closure (no scope info).
1052 native_context()->set_closure(*empty_function); 1061 native_context()->set_closure(*empty_function);
1053 native_context()->set_previous(NULL); 1062 native_context()->set_previous(NULL);
1054 // Set extension and global object. 1063 // Set extension and global object.
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
1584 static const int num_fields = JSRegExp::kInObjectFieldCount; 1593 static const int num_fields = JSRegExp::kInObjectFieldCount;
1585 initial_map->SetInObjectProperties(num_fields); 1594 initial_map->SetInObjectProperties(num_fields);
1586 initial_map->set_unused_property_fields(0); 1595 initial_map->set_unused_property_fields(0);
1587 initial_map->set_instance_size(initial_map->instance_size() + 1596 initial_map->set_instance_size(initial_map->instance_size() +
1588 num_fields * kPointerSize); 1597 num_fields * kPointerSize);
1589 } 1598 }
1590 1599
1591 { // -- E r r o r 1600 { // -- E r r o r
1592 InstallError(isolate, global, factory->Error_string(), 1601 InstallError(isolate, global, factory->Error_string(),
1593 Context::ERROR_FUNCTION_INDEX); 1602 Context::ERROR_FUNCTION_INDEX);
1603 InstallMakeError(isolate, isolate->builtins()->MakeError(),
1604 Context::MAKE_ERROR_INDEX);
1594 } 1605 }
1595 1606
1596 { // -- E v a l E r r o r 1607 { // -- E v a l E r r o r
1597 InstallError(isolate, global, factory->EvalError_string(), 1608 InstallError(isolate, global, factory->EvalError_string(),
1598 Context::EVAL_ERROR_FUNCTION_INDEX); 1609 Context::EVAL_ERROR_FUNCTION_INDEX);
1599 } 1610 }
1600 1611
1601 { // -- R a n g e E r r o r 1612 { // -- R a n g e E r r o r
1602 InstallError(isolate, global, factory->RangeError_string(), 1613 InstallError(isolate, global, factory->RangeError_string(),
1603 Context::RANGE_ERROR_FUNCTION_INDEX); 1614 Context::RANGE_ERROR_FUNCTION_INDEX);
1615 InstallMakeError(isolate, isolate->builtins()->MakeRangeError(),
1616 Context::MAKE_RANGE_ERROR_INDEX);
1604 } 1617 }
1605 1618
1606 { // -- R e f e r e n c e E r r o r 1619 { // -- R e f e r e n c e E r r o r
1607 InstallError(isolate, global, factory->ReferenceError_string(), 1620 InstallError(isolate, global, factory->ReferenceError_string(),
1608 Context::REFERENCE_ERROR_FUNCTION_INDEX); 1621 Context::REFERENCE_ERROR_FUNCTION_INDEX);
1609 } 1622 }
1610 1623
1611 { // -- S y n t a x E r r o r 1624 { // -- S y n t a x E r r o r
1612 InstallError(isolate, global, factory->SyntaxError_string(), 1625 InstallError(isolate, global, factory->SyntaxError_string(),
1613 Context::SYNTAX_ERROR_FUNCTION_INDEX); 1626 Context::SYNTAX_ERROR_FUNCTION_INDEX);
1627 InstallMakeError(isolate, isolate->builtins()->MakeSyntaxError(),
1628 Context::MAKE_SYNTAX_ERROR_INDEX);
1614 } 1629 }
1615 1630
1616 { // -- T y p e E r r o r 1631 { // -- T y p e E r r o r
1617 InstallError(isolate, global, factory->TypeError_string(), 1632 InstallError(isolate, global, factory->TypeError_string(),
1618 Context::TYPE_ERROR_FUNCTION_INDEX); 1633 Context::TYPE_ERROR_FUNCTION_INDEX);
1634 InstallMakeError(isolate, isolate->builtins()->MakeTypeError(),
1635 Context::MAKE_TYPE_ERROR_INDEX);
1619 } 1636 }
1620 1637
1621 { // -- U R I E r r o r 1638 { // -- U R I E r r o r
1622 InstallError(isolate, global, factory->URIError_string(), 1639 InstallError(isolate, global, factory->URIError_string(),
1623 Context::URI_ERROR_FUNCTION_INDEX); 1640 Context::URI_ERROR_FUNCTION_INDEX);
1641 InstallMakeError(isolate, isolate->builtins()->MakeURIError(),
1642 Context::MAKE_URI_ERROR_INDEX);
1624 } 1643 }
1625 1644
1626 // Initialize the embedder data slot. 1645 // Initialize the embedder data slot.
1627 Handle<FixedArray> embedder_data = factory->NewFixedArray(3); 1646 Handle<FixedArray> embedder_data = factory->NewFixedArray(3);
1628 native_context()->set_embedder_data(*embedder_data); 1647 native_context()->set_embedder_data(*embedder_data);
1629 1648
1630 { // -- J S O N 1649 { // -- J S O N
1631 Handle<String> name = factory->InternalizeUtf8String("JSON"); 1650 Handle<String> name = factory->InternalizeUtf8String("JSON");
1632 Handle<JSFunction> cons = factory->NewFunction(name); 1651 Handle<JSFunction> cons = factory->NewFunction(name);
1633 JSFunction::SetInstancePrototype(cons, 1652 JSFunction::SetInstancePrototype(cons,
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
2461 Handle<JSFunction> map_iterator_function = InstallFunction( 2480 Handle<JSFunction> map_iterator_function = InstallFunction(
2462 container, "MapIterator", JS_MAP_ITERATOR_TYPE, JSMapIterator::kSize, 2481 container, "MapIterator", JS_MAP_ITERATOR_TYPE, JSMapIterator::kSize,
2463 map_iterator_prototype, Builtins::kIllegal); 2482 map_iterator_prototype, Builtins::kIllegal);
2464 native_context->set_map_iterator_map(map_iterator_function->initial_map()); 2483 native_context->set_map_iterator_map(map_iterator_function->initial_map());
2465 } 2484 }
2466 2485
2467 { // -- S c r i p t 2486 { // -- S c r i p t
2468 // Builtin functions for Script. 2487 // Builtin functions for Script.
2469 Handle<JSFunction> script_fun = InstallFunction( 2488 Handle<JSFunction> script_fun = InstallFunction(
2470 container, "Script", JS_VALUE_TYPE, JSValue::kSize, 2489 container, "Script", JS_VALUE_TYPE, JSValue::kSize,
2471 isolate->initial_object_prototype(), Builtins::kIllegal); 2490 isolate->initial_object_prototype(), Builtins::kUnsupportedThrower);
2472 Handle<JSObject> prototype = 2491 Handle<JSObject> prototype =
Yang 2016/08/08 15:14:09 I would keep it the old way. We would crash in deb
jgruber 2016/08/09 06:59:15 I'm not completely sure what you mean. This should
2473 factory->NewJSObject(isolate->object_function(), TENURED); 2492 factory->NewJSObject(isolate->object_function(), TENURED);
2474 Accessors::FunctionSetPrototype(script_fun, prototype).Assert(); 2493 Accessors::FunctionSetPrototype(script_fun, prototype).Assert();
2475 native_context->set_script_function(*script_fun); 2494 native_context->set_script_function(*script_fun);
2476 2495
2477 Handle<Map> script_map = Handle<Map>(script_fun->initial_map()); 2496 Handle<Map> script_map = Handle<Map>(script_fun->initial_map());
2478 Map::EnsureDescriptorSlack(script_map, 15); 2497 Map::EnsureDescriptorSlack(script_map, 15);
2479 2498
2480 PropertyAttributes attribs = 2499 PropertyAttributes attribs =
2481 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 2500 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
2482 2501
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
2698 2717
2699 Handle<JSFunction> fun; 2718 Handle<JSFunction> fun;
2700 for (const FunctionInfo& info : infos) { 2719 for (const FunctionInfo& info : infos) {
2701 fun = SimpleInstallFunction(proto, info.name, info.id, 0, true, attrs); 2720 fun = SimpleInstallFunction(proto, info.name, info.id, 0, true, attrs);
2702 fun->shared()->set_native(true); 2721 fun->shared()->set_native(true);
2703 } 2722 }
2704 2723
2705 Accessors::FunctionSetPrototype(callsite_fun, proto).Assert(); 2724 Accessors::FunctionSetPrototype(callsite_fun, proto).Assert();
2706 } 2725 }
2707 } 2726 }
2708
2709 { // -- E r r o r
2710 Handle<JSFunction> make_err_fun = InstallFunction(
2711 container, "make_generic_error", JS_OBJECT_TYPE, JSObject::kHeaderSize,
2712 isolate->initial_object_prototype(), Builtins::kMakeGenericError);
2713 make_err_fun->shared()->DontAdaptArguments();
2714 }
2715 } 2727 }
2716 2728
2717 2729
2718 void Bootstrapper::ExportExperimentalFromRuntime(Isolate* isolate, 2730 void Bootstrapper::ExportExperimentalFromRuntime(Isolate* isolate,
2719 Handle<JSObject> container) { 2731 Handle<JSObject> container) {
2720 HandleScope scope(isolate); 2732 HandleScope scope(isolate);
2721 2733
2722 #define INITIALIZE_FLAG(FLAG) \ 2734 #define INITIALIZE_FLAG(FLAG) \
2723 { \ 2735 { \
2724 Handle<String> name = \ 2736 Handle<String> name = \
(...skipping 1352 matching lines...) Expand 10 before | Expand all | Expand 10 after
4077 } 4089 }
4078 4090
4079 4091
4080 // Called when the top-level V8 mutex is destroyed. 4092 // Called when the top-level V8 mutex is destroyed.
4081 void Bootstrapper::FreeThreadResources() { 4093 void Bootstrapper::FreeThreadResources() {
4082 DCHECK(!IsActive()); 4094 DCHECK(!IsActive());
4083 } 4095 }
4084 4096
4085 } // namespace internal 4097 } // namespace internal
4086 } // namespace v8 4098 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/builtins/builtins.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698