Index: src/runtime.cc |
diff --git a/src/runtime.cc b/src/runtime.cc |
index 24e7bc9f2b54c1bf13531eb943d2ed574e09f822..93f93d4d61e8f485bb67d7e143eec8332ff45e0f 100644 |
--- a/src/runtime.cc |
+++ b/src/runtime.cc |
@@ -116,6 +116,17 @@ namespace internal { |
static_cast<StrictModeFlag>(args.smi_at(index)); |
+// Assert that the given argument has a valid value for a LanguageMode |
+// and store it in a LanguageMode variable with the given name. |
+#define CONVERT_LANGUAGE_MODE_ARG(name, index) \ |
+ ASSERT(args[index]->IsSmi()); \ |
+ ASSERT(args.smi_at(index) == CLASSIC_MODE || \ |
+ args.smi_at(index) == STRICT_MODE || \ |
+ args.smi_at(index) == EXTENDED_MODE); \ |
+ LanguageMode name = \ |
+ static_cast<LanguageMode>(args.smi_at(index)); |
+ |
+ |
MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate, |
JSObject* boilerplate) { |
StackLimitCheck check(isolate); |
@@ -1402,13 +1413,15 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareGlobals) { |
value, |
attributes)); |
} else { |
- StrictModeFlag strict_mode = DeclareGlobalsStrictModeFlag::decode(flags); |
+ LanguageMode language_mode = DeclareGlobalsLanguageMode::decode(flags); |
+ StrictModeFlag strict_mode_flag = (language_mode == CLASSIC_MODE) |
+ ? kNonStrictMode : kStrictMode; |
RETURN_IF_EMPTY_HANDLE(isolate, |
SetProperty(global, |
name, |
value, |
static_cast<PropertyAttributes>(attr), |
- strict_mode)); |
+ strict_mode_flag)); |
} |
} |
@@ -1514,7 +1527,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareContextSlot) { |
RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { |
NoHandleAllocation nha; |
// args[0] == name |
- // args[1] == strict_mode |
+ // args[1] == language_mode |
// args[2] == value (optional) |
// Determine if we need to assign to the variable if it already |
@@ -1525,7 +1538,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { |
CONVERT_ARG_CHECKED(String, name, 0); |
GlobalObject* global = isolate->context()->global(); |
RUNTIME_ASSERT(args[1]->IsSmi()); |
- CONVERT_STRICT_MODE_ARG(strict_mode, 1); |
+ CONVERT_LANGUAGE_MODE_ARG(language_mode, 1); |
+ StrictModeFlag strict_mode_flag = (language_mode == CLASSIC_MODE) |
+ ? kNonStrictMode : kStrictMode; |
// According to ECMA-262, section 12.2, page 62, the property must |
// not be deletable. |
@@ -1554,7 +1569,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { |
// Found an interceptor that's not read only. |
if (assign) { |
return raw_holder->SetProperty( |
- &lookup, *name, args[2], attributes, strict_mode); |
+ &lookup, *name, args[2], attributes, strict_mode_flag); |
} else { |
return isolate->heap()->undefined_value(); |
} |
@@ -1566,7 +1581,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { |
// Reload global in case the loop above performed a GC. |
global = isolate->context()->global(); |
if (assign) { |
- return global->SetProperty(*name, args[2], attributes, strict_mode); |
+ return global->SetProperty(*name, args[2], attributes, strict_mode_flag); |
} |
return isolate->heap()->undefined_value(); |
} |
@@ -1933,7 +1948,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultReceiver) { |
ASSERT(args.length() == 1); |
CONVERT_CHECKED(JSFunction, function, args[0]); |
SharedFunctionInfo* shared = function->shared(); |
- if (shared->native() || shared->strict_mode()) { |
+ if (shared->native() || !shared->is_classic_mode()) { |
return isolate->heap()->undefined_value(); |
} |
// Returns undefined for strict or native functions, or |
@@ -4756,8 +4771,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) { |
CONVERT_CHECKED(JSReceiver, object, args[0]); |
CONVERT_CHECKED(String, key, args[1]); |
- CONVERT_SMI_ARG_CHECKED(strict, 2); |
- return object->DeleteProperty(key, (strict == kStrictMode) |
+ CONVERT_STRICT_MODE_ARG(strict_mode, 2); |
+ return object->DeleteProperty(key, (strict_mode == kStrictMode) |
? JSReceiver::STRICT_DELETION |
: JSReceiver::NORMAL_DELETION); |
} |
@@ -5183,7 +5198,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArgumentsProperty) { |
if (key->Equals(isolate->heap()->callee_symbol())) { |
Object* function = frame->function(); |
if (function->IsJSFunction() && |
- JSFunction::cast(function)->shared()->strict_mode()) { |
+ !JSFunction::cast(function)->shared()->is_classic_mode()) { |
return isolate->Throw(*isolate->factory()->NewTypeError( |
"strict_arguments_callee", HandleVector<Object>(NULL, 0))); |
} |
@@ -9110,7 +9125,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreContextSlot) { |
Handle<Object> value(args[0], isolate); |
CONVERT_ARG_CHECKED(Context, context, 1); |
CONVERT_ARG_CHECKED(String, name, 2); |
- CONVERT_STRICT_MODE_ARG(strict_mode, 3); |
+ CONVERT_LANGUAGE_MODE_ARG(language_mode, 3); |
+ StrictModeFlag strict_mode = (language_mode == CLASSIC_MODE) |
+ ? kNonStrictMode : kStrictMode; |
int index; |
PropertyAttributes attributes; |
@@ -9478,7 +9495,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileString) { |
// Compile source string in the global context. |
Handle<SharedFunctionInfo> shared = Compiler::CompileEval( |
- source, context, true, kNonStrictMode, RelocInfo::kNoPosition); |
+ source, context, true, CLASSIC_MODE, RelocInfo::kNoPosition); |
if (shared.is_null()) return Failure::Exception(); |
Handle<JSFunction> fun = |
isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, |
@@ -9491,7 +9508,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileString) { |
static ObjectPair CompileGlobalEval(Isolate* isolate, |
Handle<String> source, |
Handle<Object> receiver, |
- StrictModeFlag strict_mode, |
+ LanguageMode language_mode, |
int scope_position) { |
Handle<Context> context = Handle<Context>(isolate->context()); |
Handle<Context> global_context = Handle<Context>(context->global_context()); |
@@ -9510,7 +9527,7 @@ static ObjectPair CompileGlobalEval(Isolate* isolate, |
source, |
Handle<Context>(isolate->context()), |
context->IsGlobalContext(), |
- strict_mode, |
+ language_mode, |
scope_position); |
if (shared.is_null()) return MakePair(Failure::Exception(), NULL); |
Handle<JSFunction> compiled = |
@@ -9536,12 +9553,12 @@ RUNTIME_FUNCTION(ObjectPair, Runtime_ResolvePossiblyDirectEval) { |
return MakePair(*callee, isolate->heap()->the_hole_value()); |
} |
- CONVERT_STRICT_MODE_ARG(strict_mode, 3); |
+ CONVERT_LANGUAGE_MODE_ARG(language_mode, 3); |
ASSERT(args[4]->IsSmi()); |
return CompileGlobalEval(isolate, |
args.at<String>(1), |
args.at<Object>(2), |
- strict_mode, |
+ language_mode, |
args.smi_at(4)); |
} |
@@ -9555,9 +9572,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetNewFunctionAttributes) { |
ASSERT(args.length() == 1); |
CONVERT_ARG_CHECKED(JSFunction, func, 0); |
- Handle<Map> map = func->shared()->strict_mode() |
- ? isolate->strict_mode_function_instance_map() |
- : isolate->function_instance_map(); |
+ Handle<Map> map = func->shared()->is_classic_mode() |
+ ? isolate->function_instance_map() |
+ : isolate->strict_mode_function_instance_map(); |
ASSERT(func->map()->instance_type() == map->instance_type()); |
ASSERT(func->map()->instance_size() == map->instance_size()); |
@@ -11017,7 +11034,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFrameDetails) { |
// THIS MUST BE DONE LAST SINCE WE MIGHT ADVANCE |
// THE FRAME ITERATOR TO WRAP THE RECEIVER. |
Handle<Object> receiver(it.frame()->receiver(), isolate); |
- if (!receiver->IsJSObject() && !shared->strict_mode() && !shared->native()) { |
+ if (!receiver->IsJSObject() && |
+ shared->is_classic_mode() && |
+ !shared->native()) { |
// If the receiver is not a JSObject and the function is not a |
// builtin or strict-mode we have hit an optimization where a |
// value object is not converted into a wrapped JS objects. To |
@@ -12156,7 +12175,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugEvaluate) { |
Compiler::CompileEval(function_source, |
context, |
context->IsGlobalContext(), |
- kNonStrictMode, |
+ CLASSIC_MODE, |
RelocInfo::kNoPosition); |
if (shared.is_null()) return Failure::Exception(); |
Handle<JSFunction> compiled_function = |
@@ -12253,7 +12272,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugEvaluateGlobal) { |
Compiler::CompileEval(source, |
context, |
is_global, |
- kNonStrictMode, |
+ CLASSIC_MODE, |
RelocInfo::kNoPosition); |
if (shared.is_null()) return Failure::Exception(); |
Handle<JSFunction> compiled_function = |