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

Unified Diff: src/bootstrapper.cc

Issue 7067017: Change strict mode poison pill to be the samme type error function (fixes issue 1387). (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/builtins.h » ('j') | src/messages.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/bootstrapper.cc
===================================================================
--- src/bootstrapper.cc (revision 8009)
+++ src/bootstrapper.cc (working copy)
@@ -171,7 +171,7 @@
// Creates the empty function. Used for creating a context from scratch.
Handle<JSFunction> CreateEmptyFunction(Isolate* isolate);
// Creates the ThrowTypeError function. ECMA 5th Ed. 13.2.3
- Handle<JSFunction> CreateThrowTypeErrorFunction(Builtins::Name builtin);
+ Handle<JSFunction> GetThrowTypeErrorFunction();
void CreateStrictModeFunctionMaps(Handle<JSFunction> empty);
// Creates the global objects using the global and the template passed in
@@ -265,6 +265,7 @@
// These are the final, writable prototype, maps.
Handle<Map> function_instance_map_writable_prototype_;
Handle<Map> strict_mode_function_instance_map_writable_prototype_;
+ Handle<JSFunction> throw_type_error_function;
BootstrapperActive active_;
friend class Bootstrapper;
@@ -549,22 +550,24 @@
// ECMAScript 5th Edition, 13.2.3
-Handle<JSFunction> Genesis::CreateThrowTypeErrorFunction(
- Builtins::Name builtin) {
- Handle<String> name = factory()->LookupAsciiSymbol("ThrowTypeError");
- Handle<JSFunction> throw_type_error =
+Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() {
+ if (throw_type_error_function.is_null()) {
+ Handle<String> name = factory()->LookupAsciiSymbol("ThrowTypeError");
+ throw_type_error_function =
factory()->NewFunctionWithoutPrototype(name, kStrictMode);
Lasse Reichstein 2011/05/24 09:44:10 It's should not be a strict function. If it's a st
Lasse Reichstein 2011/05/24 09:44:10 Does this create a function with no .prototype pro
Rico 2011/05/24 10:46:08 Done
Rico 2011/05/24 10:46:08 It creates an empty function with a function witho
Lasse Reichstein 2011/05/24 11:00:19 That *sounds* incorrect. It should have the standa
- Handle<Code> code = Handle<Code>(
- isolate()->builtins()->builtin(builtin));
+ Handle<Code> code =
+ Handle<Code>(isolate()->builtins()->builtin(
+ Builtins::kStrictModePoisonPill));
Lasse Reichstein 2011/05/24 09:44:10 Just use an initializer instead of repeating "Hand
Rico 2011/05/24 10:46:08 Done.
- throw_type_error->set_map(global_context()->strict_mode_function_map());
- throw_type_error->set_code(*code);
- throw_type_error->shared()->set_code(*code);
- throw_type_error->shared()->DontAdaptArguments();
+ throw_type_error_function->set_map(
+ global_context()->strict_mode_function_map());
Lasse Reichstein 2011/05/24 09:44:10 Still not a strict function.
Rico 2011/05/24 10:46:08 Done.
+ throw_type_error_function->set_code(*code);
+ throw_type_error_function->shared()->set_code(*code);
+ throw_type_error_function->shared()->DontAdaptArguments();
- PreventExtensions(throw_type_error);
-
- return throw_type_error;
+ PreventExtensions(throw_type_error_function);
+ }
+ return throw_type_error_function;
}
@@ -621,17 +624,15 @@
CreateStrictModeFunctionMap(
ADD_WRITEABLE_PROTOTYPE, empty, arguments, caller);
- // Create the ThrowTypeError function instances.
- Handle<JSFunction> arguments_throw =
- CreateThrowTypeErrorFunction(Builtins::kStrictFunctionArguments);
- Handle<JSFunction> caller_throw =
- CreateThrowTypeErrorFunction(Builtins::kStrictFunctionCaller);
+ // Create the ThrowTypeError function instance.
+ Handle<JSFunction> throw_function =
+ GetThrowTypeErrorFunction();
// Complete the callback fixed arrays.
- arguments->set(0, *arguments_throw);
- arguments->set(1, *arguments_throw);
- caller->set(0, *caller_throw);
- caller->set(1, *caller_throw);
+ arguments->set(0, *throw_function);
+ arguments->set(1, *throw_function);
+ caller->set(0, *throw_function);
+ caller->set(1, *throw_function);
}
@@ -1061,16 +1062,14 @@
Handle<FixedArray> callee = factory->NewFixedArray(2, TENURED);
Handle<FixedArray> caller = factory->NewFixedArray(2, TENURED);
- Handle<JSFunction> callee_throw =
- CreateThrowTypeErrorFunction(Builtins::kStrictArgumentsCallee);
- Handle<JSFunction> caller_throw =
- CreateThrowTypeErrorFunction(Builtins::kStrictArgumentsCaller);
+ Handle<JSFunction> throw_function =
+ GetThrowTypeErrorFunction();
// Install the ThrowTypeError functions.
- callee->set(0, *callee_throw);
- callee->set(1, *callee_throw);
- caller->set(0, *caller_throw);
- caller->set(1, *caller_throw);
+ callee->set(0, *throw_function);
+ callee->set(1, *throw_function);
+ caller->set(0, *throw_function);
+ caller->set(1, *throw_function);
// Create the descriptor array for the arguments object.
Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(3);
« no previous file with comments | « no previous file | src/builtins.h » ('j') | src/messages.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698