Index: src/bootstrapper.cc |
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc |
index 0f3cd1b9203ffb219382630f1ee9bae8ecd217f5..73b83215e1a8ade87fcc94d941332682021b5c84 100644 |
--- a/src/bootstrapper.cc |
+++ b/src/bootstrapper.cc |
@@ -1014,17 +1014,38 @@ void Genesis::HookUpGlobalObject(Handle<JSGlobalObject> global_object) { |
} |
-static void SimpleInstallFunction(Handle<JSObject> base, Handle<Name> name, |
- Builtins::Name call, int len, bool adapt) { |
+static Handle<JSFunction> SimpleInstallFunction(Handle<JSObject> base, |
+ Handle<Name> name, |
+ Builtins::Name call, int len, |
+ bool adapt, |
+ bool with_prototype = false) { |
+ Isolate* isolate = base->GetIsolate(); |
+ MaybeHandle<JSObject> prototype = |
+ with_prototype |
+ ? isolate->factory()->NewJSObject(isolate->object_function(), TENURED) |
+ : MaybeHandle<JSObject>(); |
+ |
Handle<JSFunction> fun = |
InstallFunction(base, name, JS_OBJECT_TYPE, JSObject::kHeaderSize, |
- MaybeHandle<JSObject>(), call, DONT_ENUM); |
+ prototype, call, DONT_ENUM); |
if (adapt) { |
fun->shared()->set_internal_formal_parameter_count(len); |
} else { |
fun->shared()->DontAdaptArguments(); |
} |
fun->shared()->set_length(len); |
+ return fun; |
+} |
+ |
+ |
+static Handle<JSFunction> SimpleInstallFunction(Handle<JSObject> base, |
+ const char* name, |
+ Builtins::Name call, int len, |
+ bool adapt, |
+ bool with_prototype = false) { |
+ return SimpleInstallFunction( |
+ base, base->GetIsolate()->factory()->InternalizeUtf8String(name), call, |
+ len, adapt, with_prototype); |
} |
@@ -1126,9 +1147,8 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, |
initial_strong_map->set_is_strong(); |
CacheInitialJSArrayMaps(native_context(), initial_strong_map); |
- SimpleInstallFunction(array_function, |
- factory->NewStringFromAsciiChecked("isArray"), |
- Builtins::kArrayIsArray, 1, true); |
+ SimpleInstallFunction(array_function, "isArray", Builtins::kArrayIsArray, 1, |
+ true); |
} |
{ // --- N u m b e r --- |
@@ -1234,6 +1254,55 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, |
num_fields * kPointerSize); |
} |
+ { // -- E r r o r |
+ Handle<JSFunction> error_fun = SimpleInstallFunction( |
+ global, "Error", Builtins::kIllegal, 0, true, true); |
+ InstallWithIntrinsicDefaultProto(isolate, error_fun, |
+ Context::ERROR_FUNCTION_INDEX); |
+ } |
+ |
+ { // -- E v a l E r r o r |
+ Handle<JSFunction> eval_error_fun = SimpleInstallFunction( |
+ global, "EvalError", Builtins::kIllegal, 0, true, true); |
+ InstallWithIntrinsicDefaultProto(isolate, eval_error_fun, |
+ Context::EVAL_ERROR_FUNCTION_INDEX); |
+ } |
+ |
+ { // -- R a n g e E r r o r |
+ Handle<JSFunction> range_error_fun = SimpleInstallFunction( |
+ global, "RangeError", Builtins::kIllegal, 0, true, true); |
+ InstallWithIntrinsicDefaultProto(isolate, range_error_fun, |
+ Context::RANGE_ERROR_FUNCTION_INDEX); |
+ } |
+ |
+ { // -- R e f e r e n c e E r r o r |
+ Handle<JSFunction> reference_error_fun = SimpleInstallFunction( |
+ global, "ReferenceError", Builtins::kIllegal, 0, true, true); |
+ InstallWithIntrinsicDefaultProto(isolate, reference_error_fun, |
+ Context::REFERENCE_ERROR_FUNCTION_INDEX); |
+ } |
+ |
+ { // -- S y n t a x E r r o r |
+ Handle<JSFunction> syntax_error_fun = SimpleInstallFunction( |
+ global, "SyntaxError", Builtins::kIllegal, 0, true, true); |
+ InstallWithIntrinsicDefaultProto(isolate, syntax_error_fun, |
+ Context::SYNTAX_ERROR_FUNCTION_INDEX); |
+ } |
+ |
+ { // -- T y p e E r r o r |
+ Handle<JSFunction> type_error_fun = SimpleInstallFunction( |
+ global, "TypeError", Builtins::kIllegal, 0, true, true); |
+ InstallWithIntrinsicDefaultProto(isolate, type_error_fun, |
+ Context::TYPE_ERROR_FUNCTION_INDEX); |
+ } |
+ |
+ { // -- U R I E r r o r |
+ Handle<JSFunction> uri_error_fun = SimpleInstallFunction( |
+ global, "URIError", Builtins::kIllegal, 0, true, true); |
+ InstallWithIntrinsicDefaultProto(isolate, uri_error_fun, |
+ Context::URI_ERROR_FUNCTION_INDEX); |
+ } |
+ |
// Initialize the embedder data slot. |
Handle<FixedArray> embedder_data = factory->NewFixedArray(3); |
native_context()->set_embedder_data(*embedder_data); |