This CL introduces a third mode next to the non-strict
(henceforth called 'classic mode') and 'strict mode'
which is called 'extended mode' as in the current
ES.next specification drafts. The extended mode is based on
the 'strict mode' and adds new functionality to it. This
means that most of the semantics of these two modes
coincide.
The 'extended mode' is entered instead of the 'strict mode'
during parsing when using the 'strict mode' directive
"use strict" and when the the harmony-scoping flag is
active. This should be changed once it is fully specified how the 'extended
mode' is entered.
This change introduces a new 3 valued enum LanguageMode
(see globals.h) corresponding to the modes which is mostly
used by the frontend code. This includes the following
components:
* (Pre)Parser
* Compiler
* SharedFunctionInfo, Scope and ScopeInfo
* runtime functions: StoreContextSlot,
ResolvePossiblyDirectEval, InitializeVarGlobal,
DeclareGlobals
The old enum StrictModeFlag is still used in the backend
when the distinction between the 'strict mode' and the 'extended mode' does
not matter. This includes:
* SetProperty runtime function, Delete builtin
* StoreIC and KeyedStoreIC
* StubCache
Review URL: http://codereview.chromium.org/8417035
http://code.google.com/p/v8/source/detail?r=10062
Modified:
/branches/bleeding_edge/src/accessors.cc
/branches/bleeding_edge/src/arm/code-stubs-arm.cc
/branches/bleeding_edge/src/arm/full-codegen-arm.cc
/branches/bleeding_edge/src/arm/lithium-arm.h
/branches/bleeding_edge/src/arm/lithium-codegen-arm.cc
/branches/bleeding_edge/src/arm/lithium-codegen-arm.h
/branches/bleeding_edge/src/arm/stub-cache-arm.cc
/branches/bleeding_edge/src/ast.cc
/branches/bleeding_edge/src/ast.h
/branches/bleeding_edge/src/bootstrapper.cc
/branches/bleeding_edge/src/code-stubs.h
/branches/bleeding_edge/src/compilation-cache.cc
/branches/bleeding_edge/src/compilation-cache.h
/branches/bleeding_edge/src/compiler.cc
/branches/bleeding_edge/src/compiler.h
/branches/bleeding_edge/src/execution.cc
/branches/bleeding_edge/src/factory.cc
/branches/bleeding_edge/src/factory.h
/branches/bleeding_edge/src/flag-definitions.h
/branches/bleeding_edge/src/full-codegen.cc
/branches/bleeding_edge/src/full-codegen.h
/branches/bleeding_edge/src/globals.h
/branches/bleeding_edge/src/handles.h
/branches/bleeding_edge/src/heap.cc
/branches/bleeding_edge/src/hydrogen-instructions.h
/branches/bleeding_edge/src/hydrogen.cc
/branches/bleeding_edge/src/hydrogen.h
/branches/bleeding_edge/src/ia32/code-stubs-ia32.cc
/branches/bleeding_edge/src/ia32/full-codegen-ia32.cc
/branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc
/branches/bleeding_edge/src/ia32/lithium-codegen-ia32.h
/branches/bleeding_edge/src/ia32/lithium-ia32.h
/branches/bleeding_edge/src/ia32/stub-cache-ia32.cc
/branches/bleeding_edge/src/ic.cc
/branches/bleeding_edge/src/mips/code-stubs-mips.cc
/branches/bleeding_edge/src/mips/full-codegen-mips.cc
/branches/bleeding_edge/src/mips/lithium-codegen-mips.cc
/branches/bleeding_edge/src/mips/lithium-codegen-mips.h
/branches/bleeding_edge/src/mips/lithium-mips.h
/branches/bleeding_edge/src/mips/stub-cache-mips.cc
/branches/bleeding_edge/src/objects-inl.h
/branches/bleeding_edge/src/objects.cc
/branches/bleeding_edge/src/objects.h
/branches/bleeding_edge/src/parser.cc
/branches/bleeding_edge/src/parser.h
/branches/bleeding_edge/src/preparse-data.h
/branches/bleeding_edge/src/preparser.cc
/branches/bleeding_edge/src/preparser.h
/branches/bleeding_edge/src/runtime.cc
/branches/bleeding_edge/src/runtime.h
/branches/bleeding_edge/src/scopeinfo.cc
/branches/bleeding_edge/src/scopes.cc
/branches/bleeding_edge/src/scopes.h
/branches/bleeding_edge/src/x64/code-stubs-x64.cc
/branches/bleeding_edge/src/x64/full-codegen-x64.cc
/branches/bleeding_edge/src/x64/lithium-codegen-x64.cc
/branches/bleeding_edge/src/x64/lithium-codegen-x64.h
/branches/bleeding_edge/src/x64/lithium-x64.h
/branches/bleeding_edge/src/x64/stub-cache-x64.cc
/branches/bleeding_edge/test/cctest/test-parsing.cc
/branches/bleeding_edge/test/mjsunit/debug-scopes.js
/branches/bleeding_edge/test/mjsunit/harmony/block-conflicts.js
/branches/bleeding_edge/test/mjsunit/harmony/block-for.js
/branches/bleeding_edge/test/mjsunit/harmony/block-leave.js
/branches/bleeding_edge/test/mjsunit/harmony/block-let-crankshaft.js
/branches/bleeding_edge/test/mjsunit/harmony/block-let-declaration.js
/branches/bleeding_edge/test/mjsunit/harmony/block-let-semantics.js
/branches/bleeding_edge/test/mjsunit/harmony/block-scoping.js
/branches/bleeding_edge/test/mjsunit/harmony/debug-blockscopes.js
/branches/bleeding_edge/test/mjsunit/harmony/debug-evaluate-blockscopes.js
=======================================
--- /branches/bleeding_edge/src/accessors.cc Thu Nov 3 03:36:55 2011
+++ /branches/bleeding_edge/src/accessors.cc Thu Nov 24 07:17:04 2011
@@ -675,7 +675,7 @@
Isolate* isolate,
JSFunction* caller) {
DisableAssertNoAllocation enable_allocation;
- if (caller->shared()->strict_mode()) {
+ if (!caller->shared()->is_classic_mode()) {
return isolate->Throw(
*isolate->factory()->NewTypeError("strict_caller",
HandleVector<Object>(NULL, 0)));
=======================================
--- /branches/bleeding_edge/src/arm/code-stubs-arm.cc Thu Nov 24 03:07:39
2011
+++ /branches/bleeding_edge/src/arm/code-stubs-arm.cc Thu Nov 24 07:17:04
2011
@@ -98,9 +98,9 @@
&gc,
TAG_OBJECT);
- int map_index = strict_mode_ == kStrictMode
- ? Context::STRICT_MODE_FUNCTION_MAP_INDEX
- : Context::FUNCTION_MAP_INDEX;
+ int map_index = (language_mode_ == CLASSIC_MODE)
+ ? Context::FUNCTION_MAP_INDEX
+ : Context::STRICT_MODE_FUNCTION_MAP_INDEX;
// Compute the function map in the current global context and set that
// as the map of the allocated object.
=======================================
--- /branches/bleeding_edge/src/arm/full-codegen-arm.cc Wed Nov 23 07:01:20
2011
+++ /branches/bleeding_edge/src/arm/full-codegen-arm.cc Thu Nov 24 07:17:04
2011
@@ -143,7 +143,7 @@
// with undefined when called as functions (without an explicit
// receiver object). r5 is zero for method calls and non-zero for
// function calls.
- if (info->is_strict_mode() || info->is_native()) {
+ if (!info->is_classic_mode() || info->is_native()) {
Label ok;
__ cmp(r5, Operand(0));
__ b(eq, &ok);
@@ -236,7 +236,7 @@
// The stub will rewrite receiever and parameter count if the previous
// stack frame was an arguments adapter frame.
ArgumentsAccessStub::Type type;
- if (is_strict_mode()) {
+ if (!is_classic_mode()) {
type = ArgumentsAccessStub::NEW_STRICT;
} else if (function()->has_duplicate_parameters()) {
type = ArgumentsAccessStub::NEW_NON_STRICT_SLOW;
@@ -1115,7 +1115,7 @@
!pretenure &&
scope()->is_function_scope() &&
info->num_literals() == 0) {
- FastNewClosureStub stub(info->strict_mode_flag());
+ FastNewClosureStub stub(info->language_mode());
__ mov(r0, Operand(info));
__ push(r0);
__ CallStub(&stub);
@@ -1471,9 +1471,9 @@
VisitForAccumulatorValue(value);
__ mov(r2, Operand(key->handle()));
__ ldr(r1, MemOperand(sp));
- Handle<Code> ic = is_strict_mode()
- ? isolate()->builtins()->StoreIC_Initialize_Strict()
- : isolate()->builtins()->StoreIC_Initialize();
+ Handle<Code> ic = is_classic_mode()
+ ? isolate()->builtins()->StoreIC_Initialize()
+ : isolate()->builtins()->StoreIC_Initialize_Strict();
__ Call(ic, RelocInfo::CODE_TARGET, key->id());
PrepareForBailoutForId(key->id(), NO_REGISTERS);
} else {
@@ -1879,9 +1879,9 @@
__ mov(r1, r0);
__ pop(r0); // Restore value.
__ mov(r2, Operand(prop->key()->AsLiteral()->handle()));
- Handle<Code> ic = is_strict_mode()
- ? isolate()->builtins()->StoreIC_Initialize_Strict()
- : isolate()->builtins()->StoreIC_Initialize();
+ Handle<Code> ic = is_classic_mode()
+ ? isolate()->builtins()->StoreIC_Initialize()
+ : isolate()->builtins()->StoreIC_Initialize_Strict();
__ Call(ic);
break;
}
@@ -1892,9 +1892,9 @@
__ mov(r1, r0);
__ pop(r2);
__ pop(r0); // Restore value.
- Handle<Code> ic = is_strict_mode()
- ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict()
- : isolate()->builtins()->KeyedStoreIC_Initialize();
+ Handle<Code> ic = is_classic_mode()
+ ? isolate()->builtins()->KeyedStoreIC_Initialize()
+ : isolate()->builtins()->KeyedStoreIC_Initialize_Strict();
__ Call(ic);
break;
}
@@ -1910,9 +1910,9 @@
// Global var, const, or let.
__ mov(r2, Operand(var->name()));
__ ldr(r1, GlobalObjectOperand());
- Handle<Code> ic = is_strict_mode()
- ? isolate()->builtins()->StoreIC_Initialize_Strict()
- : isolate()->builtins()->StoreIC_Initialize();
+ Handle<Code> ic = is_classic_mode()
+ ? isolate()->builtins()->StoreIC_Initialize()
+ : isolate()->builtins()->StoreIC_Initialize_Strict();
__ Call(ic, RelocInfo::CODE_TARGET_CONTEXT);
} else if (op == Token::INIT_CONST) {
@@ -1943,7 +1943,7 @@
if (var->IsLookupSlot()) {
__ push(r0); // Value.
__ mov(r1, Operand(var->name()));
- __ mov(r0, Operand(Smi::FromInt(strict_mode_flag())));
+ __ mov(r0, Operand(Smi::FromInt(language_mode())));
__ Push(cp, r1, r0); // Context, name, strict mode.
__ CallRuntime(Runtime::kStoreContextSlot, 4);
} else {
@@ -1991,7 +1991,7 @@
ASSERT(var->IsLookupSlot());
__ push(r0); // Value.
__ mov(r1, Operand(var->name()));
- __ mov(r0, Operand(Smi::FromInt(strict_mode_flag())));
+ __ mov(r0, Operand(Smi::FromInt(language_mode())));
__ Push(cp, r1, r0); // Context, name, strict mode.
__ CallRuntime(Runtime::kStoreContextSlot, 4);
}
@@ -2028,9 +2028,9 @@
__ pop(r1);
}
- Handle<Code> ic = is_strict_mode()
- ? isolate()->builtins()->StoreIC_Initialize_Strict()
- : isolate()->builtins()->StoreIC_Initialize();
+ Handle<Code> ic = is_classic_mode()
+ ? isolate()->builtins()->StoreIC_Initialize()
+ : isolate()->builtins()->StoreIC_Initialize_Strict();
__ Call(ic, RelocInfo::CODE_TARGET, expr->id());
// If the assignment ends an initialization block, revert to fast case.
@@ -2074,9 +2074,9 @@
__ pop(r2);
}
- Handle<Code> ic = is_strict_mode()
- ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict()
- : isolate()->builtins()->KeyedStoreIC_Initialize();
+ Handle<Code> ic = is_classic_mode()
+ ? isolate()->builtins()->KeyedStoreIC_Initialize()
+ : isolate()->builtins()->KeyedStoreIC_Initialize_Strict();
__ Call(ic, RelocInfo::CODE_TARGET, expr->id());
// If the assignment ends an initialization block, revert to fast case.
@@ -2199,21 +2199,19 @@
}
__ push(r1);
- // Push the receiver of the enclosing function and do runtime call.
+ // Push the receiver of the enclosing function.
int receiver_offset = 2 + info_->scope()->num_parameters();
__ ldr(r1, MemOperand(fp, receiver_offset * kPointerSize));
__ push(r1);
- // Push the strict mode flag. In harmony mode every eval call
- // is a strict mode eval call.
- StrictModeFlag strict_mode =
- FLAG_harmony_scoping ? kStrictMode : strict_mode_flag();
- __ mov(r1, Operand(Smi::FromInt(strict_mode)));
+ // Push the language mode.
+ __ mov(r1, Operand(Smi::FromInt(language_mode())));
__ push(r1);
// Push the start position of the scope the calls resides in.
__ mov(r1, Operand(Smi::FromInt(scope()->start_position())));
__ push(r1);
+ // Do the runtime call.
__ CallRuntime(Runtime::kResolvePossiblyDirectEval, 5);
}
@@ -3707,7 +3705,9 @@
if (property != NULL) {
VisitForStackValue(property->obj());
VisitForStackValue(property->key());
- __ mov(r1, Operand(Smi::FromInt(strict_mode_flag())));
+ StrictModeFlag strict_mode_flag = (language_mode() == CLASSIC_MODE)
+ ? kNonStrictMode : kStrictMode;
+ __ mov(r1, Operand(Smi::FromInt(strict_mode_flag)));
__ push(r1);
__ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
context()->Plug(r0);
@@ -3715,7 +3715,7 @@
Variable* var = proxy->var();
// Delete of an unqualified identifier is disallowed in strict mode
// but "delete this" is allowed.
- ASSERT(strict_mode_flag() == kNonStrictMode || var->is_this());
+ ASSERT(language_mode() == CLASSIC_MODE || var->is_this());
if (var->IsUnallocated()) {
__ ldr(r2, GlobalObjectOperand());
__ mov(r1, Operand(var->name()));
@@ -3979,9 +3979,9 @@
case NAMED_PROPERTY: {
__ mov(r2, Operand(prop->key()->AsLiteral()->handle()));
__ pop(r1);
- Handle<Code> ic = is_strict_mode()
- ? isolate()->builtins()->StoreIC_Initialize_Strict()
- : isolate()->builtins()->StoreIC_Initialize();
+ Handle<Code> ic = is_classic_mode()
+ ? isolate()->builtins()->StoreIC_Initialize()
+ : isolate()->builtins()->StoreIC_Initialize_Strict();
__ Call(ic, RelocInfo::CODE_TARGET, expr->id());
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
if (expr->is_postfix()) {
@@ -3996,9 +3996,9 @@
case KEYED_PROPERTY: {
__ pop(r1); // Key.
__ pop(r2); // Receiver.
- Handle<Code> ic = is_strict_mode()
- ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict()
- : isolate()->builtins()->KeyedStoreIC_Initialize();
+ Handle<Code> ic = is_classic_mode()
+ ? isolate()->builtins()->KeyedStoreIC_Initialize()
+ : isolate()->builtins()->KeyedStoreIC_Initialize_Strict();
__ Call(ic, RelocInfo::CODE_TARGET, expr->id());
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
if (expr->is_postfix()) {
=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.h Thu Nov 24 05:42:52 2011
+++ /branches/bleeding_edge/src/arm/lithium-arm.h Thu Nov 24 07:17:04 2011
@@ -1259,7 +1259,7 @@
LOperand* global_object() { return InputAt(0); }
Handle<Object> name() const { return hydrogen()->name(); }
LOperand* value() { return InputAt(1); }
- bool strict_mode() { return hydrogen()->strict_mode(); }
+ StrictModeFlag strict_mode_flag() { return
hydrogen()->strict_mode_flag(); }
};
@@ -1619,7 +1619,6 @@
LOperand* value() { return inputs_[1]; }
Handle<Object> name() const { return hydrogen()->name(); }
StrictModeFlag strict_mode_flag() { return
hydrogen()->strict_mode_flag(); }
- bool strict_mode() { return strict_mode_flag() == kStrictMode; }
};
@@ -1681,7 +1680,7 @@
LOperand* object() { return inputs_[0]; }
LOperand* key() { return inputs_[1]; }
LOperand* value() { return inputs_[2]; }
- bool strict_mode() { return hydrogen()->strict_mode(); }
+ StrictModeFlag strict_mode_flag() { return
hydrogen()->strict_mode_flag(); }
};
class LStoreKeyedSpecializedArrayElement: public LTemplateInstruction<0,
3, 0> {
=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Thu Nov 24
05:42:52 2011
+++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Thu Nov 24
07:17:04 2011
@@ -143,7 +143,7 @@
// with undefined when called as functions (without an explicit
// receiver object). r5 is zero for method calls and non-zero for
// function calls.
- if (info_->is_strict_mode() || info_->is_native()) {
+ if (!info_->is_classic_mode() || info_->is_native()) {
Label ok;
__ cmp(r5, Operand(0));
__ b(eq, &ok);
@@ -2286,7 +2286,7 @@
ASSERT(ToRegister(instr->value()).is(r0));
__ mov(r2, Operand(instr->name()));
- Handle<Code> ic = instr->strict_mode()
+ Handle<Code> ic = (instr->strict_mode_flag() == kStrictMode)
? isolate()->builtins()->StoreIC_Initialize_Strict()
: isolate()->builtins()->StoreIC_Initialize();
CallCode(ic, RelocInfo::CODE_TARGET_CONTEXT, instr);
@@ -3358,7 +3358,7 @@
// Name is always in r2.
__ mov(r2, Operand(instr->name()));
- Handle<Code> ic = instr->strict_mode()
+ Handle<Code> ic = (instr->strict_mode_flag() == kStrictMode)
? isolate()->builtins()->StoreIC_Initialize_Strict()
: isolate()->builtins()->StoreIC_Initialize();
CallCode(ic, RelocInfo::CODE_TARGET, instr);
@@ -3524,7 +3524,7 @@
ASSERT(ToRegister(instr->key()).is(r1));
ASSERT(ToRegister(instr->value()).is(r0));
- Handle<Code> ic = instr->strict_mode()
+ Handle<Code> ic = (instr->strict_mode_flag() == kStrictMode)
? isolate()->builtins()->KeyedStoreIC_Initialize_Strict()
: isolate()->builtins()->KeyedStoreIC_Initialize();
CallCode(ic, RelocInfo::CODE_TARGET, instr);
@@ -4417,7 +4417,7 @@
Handle<SharedFunctionInfo> shared_info = instr->shared_info();
bool pretenure = instr->hydrogen()->pretenure();
if (!pretenure && shared_info->num_literals() == 0) {
- FastNewClosureStub stub(shared_info->strict_mode_flag());
+ FastNewClosureStub stub(shared_info->language_mode());
__ mov(r1, Operand(shared_info));
__ push(r1);
CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.h Thu Nov 24
05:42:52 2011
+++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.h Thu Nov 24
07:17:04 2011
@@ -142,7 +142,7 @@
bool is_aborted() const { return status_ == ABORTED; }
StrictModeFlag strict_mode_flag() const {
- return info()->strict_mode_flag();
+ return info()->is_classic_mode() ? kNonStrictMode : kStrictMode;
}
LChunk* chunk() const { return chunk_; }
=======================================
--- /branches/bleeding_edge/src/arm/stub-cache-arm.cc Wed Nov 9 06:32:51
2011
+++ /branches/bleeding_edge/src/arm/stub-cache-arm.cc Thu Nov 24 07:17:04
2011
@@ -2265,7 +2265,7 @@
break;
case STRING_CHECK:
- if (function->IsBuiltin() || function->shared()->strict_mode()) {
+ if (function->IsBuiltin() || !function->shared()->is_classic_mode())
{
// Check that the object is a two-byte string or a symbol.
__ CompareObjectType(r1, r3, r3, FIRST_NONSTRING_TYPE);
__ b(ge, &miss);
@@ -2283,7 +2283,7 @@
break;
case NUMBER_CHECK:
- if (function->IsBuiltin() || function->shared()->strict_mode()) {
+ if (function->IsBuiltin() || !function->shared()->is_classic_mode())
{
Label fast;
// Check that the object is a smi or a heap number.
__ JumpIfSmi(r1, &fast);
@@ -2304,7 +2304,7 @@
break;
case BOOLEAN_CHECK:
- if (function->IsBuiltin() || function->shared()->strict_mode()) {
+ if (function->IsBuiltin() || !function->shared()->is_classic_mode())
{
Label fast;
// Check that the object is a boolean.
__ LoadRoot(ip, Heap::kTrueValueRootIndex);
=======================================
--- /branches/bleeding_edge/src/ast.cc Fri Nov 18 00:59:33 2011
+++ /branches/bleeding_edge/src/ast.cc Thu Nov 24 07:17:04 2011
@@ -167,8 +167,8 @@
}
-StrictModeFlag FunctionLiteral::strict_mode_flag() const {
- return scope()->strict_mode_flag();
+LanguageMode FunctionLiteral::language_mode() const {
+ return scope()->language_mode();
}
=======================================
--- /branches/bleeding_edge/src/ast.h Fri Nov 18 00:59:33 2011
+++ /branches/bleeding_edge/src/ast.h Thu Nov 24 07:17:04 2011
@@ -1697,8 +1697,8 @@
int end_position() const;
bool is_expression() const { return IsExpression::decode(bitfield_); }
bool is_anonymous() const { return IsAnonymous::decode(bitfield_); }
- bool strict_mode() const { return strict_mode_flag() == kStrictMode; }
- StrictModeFlag strict_mode_flag() const;
+ bool is_classic_mode() const { return language_mode() == CLASSIC_MODE; }
+ LanguageMode language_mode() const;
int materialized_literal_count() { return materialized_literal_count_; }
int expected_property_count() { return expected_property_count_; }
=======================================
--- /branches/bleeding_edge/src/bootstrapper.cc Tue Nov 15 15:26:22 2011
+++ /branches/bleeding_edge/src/bootstrapper.cc Thu Nov 24 07:17:04 2011
@@ -502,7 +502,7 @@
// 262 15.3.4.
Handle<String> symbol = factory->LookupAsciiSymbol("Empty");
Handle<JSFunction> empty_function =
- factory->NewFunctionWithoutPrototype(symbol, kNonStrictMode);
+ factory->NewFunctionWithoutPrototype(symbol, CLASSIC_MODE);
// --- E m p t y ---
Handle<Code> code =
@@ -591,7 +591,7 @@
if (throw_type_error_function.is_null()) {
Handle<String> name = factory()->LookupAsciiSymbol("ThrowTypeError");
throw_type_error_function =
- factory()->NewFunctionWithoutPrototype(name, kNonStrictMode);
+ factory()->NewFunctionWithoutPrototype(name, CLASSIC_MODE);
Handle<Code> code(isolate()->builtins()->builtin(
Builtins::kStrictModePoisonPill));
throw_type_error_function->set_map(
=======================================
--- /branches/bleeding_edge/src/code-stubs.h Mon Nov 21 06:04:41 2011
+++ /branches/bleeding_edge/src/code-stubs.h Thu Nov 24 07:17:04 2011
@@ -299,16 +299,17 @@
class FastNewClosureStub : public CodeStub {
public:
- explicit FastNewClosureStub(StrictModeFlag strict_mode)
- : strict_mode_(strict_mode) { }
+ explicit FastNewClosureStub(LanguageMode language_mode)
+ : language_mode_(language_mode) { }
void Generate(MacroAssembler* masm);
private:
Major MajorKey() { return FastNewClosure; }
- int MinorKey() { return strict_mode_; }
-
- StrictModeFlag strict_mode_;
+ int MinorKey() { return language_mode_ == CLASSIC_MODE
+ ? kNonStrictMode : kStrictMode; }
+
+ LanguageMode language_mode_;
};
=======================================
--- /branches/bleeding_edge/src/compilation-cache.cc Mon Nov 14 00:58:47
2011
+++ /branches/bleeding_edge/src/compilation-cache.cc Thu Nov 24 07:17:04
2011
@@ -251,7 +251,7 @@
Handle<SharedFunctionInfo> CompilationCacheEval::Lookup(
Handle<String> source,
Handle<Context> context,
- StrictModeFlag strict_mode,
+ LanguageMode language_mode,
int scope_position) {
// Make sure not to leak the table into the surrounding handle
// scope. Otherwise, we risk keeping old tables around even after
@@ -262,7 +262,7 @@
for (generation = 0; generation < generations(); generation++) {
Handle<CompilationCacheTable> table = GetTable(generation);
result = table->LookupEval(
- *source, *context, strict_mode, scope_position);
+ *source, *context, language_mode, scope_position);
if (result->IsSharedFunctionInfo()) {
break;
}
@@ -396,7 +396,7 @@
Handle<String> source,
Handle<Context> context,
bool is_global,
- StrictModeFlag strict_mode,
+ LanguageMode language_mode,
int scope_position) {
if (!IsEnabled()) {
return Handle<SharedFunctionInfo>::null();
@@ -404,11 +404,12 @@
Handle<SharedFunctionInfo> result;
if (is_global) {
- result = eval_global_.Lookup(source, context, strict_mode,
scope_position);
+ result = eval_global_.Lookup(
+ source, context, language_mode, scope_position);
} else {
ASSERT(scope_position != RelocInfo::kNoPosition);
result = eval_contextual_.Lookup(
- source, context, strict_mode, scope_position);
+ source, context, language_mode, scope_position);
}
return result;
}
=======================================
--- /branches/bleeding_edge/src/compilation-cache.h Mon Nov 14 00:58:47 2011
+++ /branches/bleeding_edge/src/compilation-cache.h Thu Nov 24 07:17:04 2011
@@ -143,7 +143,7 @@
Handle<SharedFunctionInfo> Lookup(Handle<String> source,
Handle<Context> context,
- StrictModeFlag strict_mode,
+ LanguageMode language_mode,
int scope_position);
void Put(Handle<String> source,
@@ -214,7 +214,7 @@
Handle<SharedFunctionInfo> LookupEval(Handle<String> source,
Handle<Context> context,
bool is_global,
- StrictModeFlag strict_mode,
+ LanguageMode language_mode,
int scope_position);
// Returns the regexp data associated with the given regexp if it
=======================================
--- /branches/bleeding_edge/src/compiler.cc Mon Nov 21 06:07:46 2011
+++ /branches/bleeding_edge/src/compiler.cc Thu Nov 24 07:17:04 2011
@@ -53,7 +53,7 @@
CompilationInfo::CompilationInfo(Handle<Script> script)
: isolate_(script->GetIsolate()),
- flags_(0),
+ flags_(LanguageModeField::encode(CLASSIC_MODE)),
function_(NULL),
scope_(NULL),
global_scope_(NULL),
@@ -67,7 +67,8 @@
CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info)
: isolate_(shared_info->GetIsolate()),
- flags_(IsLazy::encode(true)),
+ flags_(LanguageModeField::encode(CLASSIC_MODE) |
+ IsLazy::encode(true)),
function_(NULL),
scope_(NULL),
global_scope_(NULL),
@@ -82,7 +83,8 @@
CompilationInfo::CompilationInfo(Handle<JSFunction> closure)
: isolate_(closure->GetIsolate()),
- flags_(IsLazy::encode(true)),
+ flags_(LanguageModeField::encode(CLASSIC_MODE) |
+ IsLazy::encode(true)),
function_(NULL),
scope_(NULL),
global_scope_(NULL),
@@ -540,7 +542,7 @@
Handle<SharedFunctionInfo> Compiler::CompileEval(Handle<String> source,
Handle<Context> context,
bool is_global,
- StrictModeFlag
strict_mode,
+ LanguageMode
language_mode,
int scope_position) {
Isolate* isolate = source->GetIsolate();
int source_length = source->length();
@@ -557,7 +559,7 @@
result = compilation_cache->LookupEval(source,
context,
is_global,
- strict_mode,
+ language_mode,
scope_position);
if (result.is_null()) {
@@ -566,15 +568,18 @@
CompilationInfo info(script);
info.MarkAsEval();
if (is_global) info.MarkAsGlobal();
- info.SetStrictModeFlag(strict_mode);
+ info.SetLanguageMode(language_mode);
info.SetCallingContext(context);
result = MakeFunctionInfo(&info);
if (!result.is_null()) {
- // If caller is strict mode, the result must be strict as well,
- // but not the other way around. Consider:
+ // If caller is strict mode, the result must be in strict mode or
+ // extended mode as well, but not the other way around. Consider:
// eval("'use strict'; ...");
- // TODO(keuchel): adapt this for extended mode.
- ASSERT(strict_mode == kNonStrictMode || result->strict_mode());
+ ASSERT(language_mode != STRICT_MODE || !result->is_classic_mode());
+ // If caller is in extended mode, the result must also be in
+ // extended mode.
+ ASSERT(language_mode != EXTENDED_MODE ||
+ result->is_extended_mode());
compilation_cache->PutEval(
source, context, is_global, result, scope_position);
}
@@ -605,14 +610,10 @@
// parsing statistics.
HistogramTimerScope timer(isolate->counters()->compile_lazy());
- // After parsing we know function's strict mode. Remember it.
- StrictModeFlag strict_mode = info->function()->strict_mode_flag();
- ASSERT(info->strict_mode_flag() == kNonStrictMode ||
- info->strict_mode_flag() == strict_mode);
- ASSERT(shared->strict_mode_flag() == kNonStrictMode ||
- shared->strict_mode_flag() == strict_mode);
- info->SetStrictModeFlag(strict_mode);
- shared->set_strict_mode_flag(strict_mode);
+ // After parsing we know the function's language mode. Remember it.
+ LanguageMode language_mode = info->function()->language_mode();
+ info->SetLanguageMode(language_mode);
+ shared->set_language_mode(language_mode);
// Compile the code.
if (!MakeCode(info)) {
@@ -691,7 +692,7 @@
CompilationInfo info(script);
info.SetFunction(literal);
info.SetScope(literal->scope());
- info.SetStrictModeFlag(literal->scope()->strict_mode_flag());
+ info.SetLanguageMode(literal->scope()->language_mode());
LiveEditFunctionTracker live_edit_tracker(info.isolate(), literal);
// Determine if the function can be lazily compiled. This is necessary to
@@ -757,7 +758,7 @@
lit->has_only_simple_this_property_assignments(),
*lit->this_property_assignments());
function_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation());
- function_info->set_strict_mode_flag(lit->strict_mode_flag());
+ function_info->set_language_mode(lit->language_mode());
function_info->set_uses_arguments(lit->scope()->arguments() != NULL);
function_info->set_has_duplicate_parameters(lit->has_duplicate_parameters());
}
=======================================
--- /branches/bleeding_edge/src/compiler.h Tue Nov 15 05:48:40 2011
+++ /branches/bleeding_edge/src/compiler.h Thu Nov 24 07:17:04 2011
@@ -52,9 +52,10 @@
bool is_lazy() const { return IsLazy::decode(flags_); }
bool is_eval() const { return IsEval::decode(flags_); }
bool is_global() const { return IsGlobal::decode(flags_); }
- bool is_strict_mode() const { return strict_mode_flag() == kStrictMode; }
- StrictModeFlag strict_mode_flag() const {
- return StrictModeFlagField::decode(flags_);
+ bool is_classic_mode() const { return language_mode() == CLASSIC_MODE; }
+ bool is_extended_mode() const { return language_mode() == EXTENDED_MODE;
}
+ LanguageMode language_mode() const {
+ return LanguageModeField::decode(flags_);
}
bool is_in_loop() const { return IsInLoop::decode(flags_); }
FunctionLiteral* function() const { return function_; }
@@ -77,10 +78,11 @@
ASSERT(!is_lazy());
flags_ |= IsGlobal::encode(true);
}
- void SetStrictModeFlag(StrictModeFlag strict_mode_flag) {
- ASSERT(StrictModeFlagField::decode(flags_) == kNonStrictMode ||
- StrictModeFlagField::decode(flags_) == strict_mode_flag);
- flags_ = StrictModeFlagField::update(flags_, strict_mode_flag);
+ void SetLanguageMode(LanguageMode language_mode) {
+ ASSERT(this->language_mode() == CLASSIC_MODE ||
+ this->language_mode() == language_mode ||
+ language_mode == EXTENDED_MODE);
+ flags_ = LanguageModeField::update(flags_, language_mode);
}
void MarkAsInLoop() {
ASSERT(is_lazy());
@@ -194,8 +196,8 @@
MarkAsNative();
}
if (!shared_info_.is_null()) {
- ASSERT(strict_mode_flag() == kNonStrictMode);
- SetStrictModeFlag(shared_info_->strict_mode_flag());
+ ASSERT(language_mode() == CLASSIC_MODE);
+ SetLanguageMode(shared_info_->language_mode());
}
}
@@ -215,7 +217,7 @@
// Flags that can be set for lazy compilation.
class IsInLoop: public BitField<bool, 3, 1> {};
// Strict mode - used in eager compilation.
- class StrictModeFlagField: public BitField<StrictModeFlag, 4, 1> {};
+ class LanguageModeField: public BitField<LanguageMode, 4, 2> {};
// Is this a function from our natives.
class IsNative: public BitField<bool, 6, 1> {};
// Is this code being compiled with support for deoptimization..
@@ -296,7 +298,7 @@
static Handle<SharedFunctionInfo> CompileEval(Handle<String> source,
Handle<Context> context,
bool is_global,
- StrictModeFlag strict_mode,
+ LanguageMode language_mode,
int scope_position);
// Compile from function info (used for lazy compilation). Returns true
on
=======================================
--- /branches/bleeding_edge/src/execution.cc Thu Oct 6 02:31:38 2011
+++ /branches/bleeding_edge/src/execution.cc Thu Nov 24 07:17:04 2011
@@ -157,7 +157,7 @@
// In non-strict mode, convert receiver.
if (convert_receiver && !receiver->IsJSReceiver() &&
- !func->shared()->native() && !func->shared()->strict_mode()) {
+ !func->shared()->native() && func->shared()->is_classic_mode()) {
if (receiver->IsUndefined() || receiver->IsNull()) {
Object* global = func->context()->global()->global_receiver();
// Under some circumstances, 'global' can be the JSBuiltinsObject
=======================================
--- /branches/bleeding_edge/src/factory.cc Mon Nov 21 02:18:47 2011
+++ /branches/bleeding_edge/src/factory.cc Thu Nov 24 07:17:04 2011
@@ -505,9 +505,9 @@
PretenureFlag pretenure) {
Handle<JSFunction> result = BaseNewFunctionFromSharedFunctionInfo(
function_info,
- function_info->strict_mode()
- ? isolate()->strict_mode_function_map()
- : isolate()->function_map(),
+ function_info->is_classic_mode()
+ ? isolate()->function_map()
+ : isolate()->strict_mode_function_map(),
pretenure);
result->set_context(*context);
@@ -759,7 +759,7 @@
Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String>
name,
Handle<Code> code)
{
Handle<JSFunction> function = NewFunctionWithoutPrototype(name,
-
kNonStrictMode);
+ CLASSIC_MODE);
function->shared()->set_code(*code);
function->set_code(*code);
ASSERT(!function->has_initial_map());
@@ -1073,11 +1073,11 @@
Handle<JSFunction> Factory::NewFunctionWithoutPrototypeHelper(
Handle<String> name,
- StrictModeFlag strict_mode) {
+ LanguageMode language_mode) {
Handle<SharedFunctionInfo> function_share = NewSharedFunctionInfo(name);
- Handle<Map> map = strict_mode == kStrictMode
- ? isolate()->strict_mode_function_without_prototype_map()
- : isolate()->function_without_prototype_map();
+ Handle<Map> map = (language_mode == CLASSIC_MODE)
+ ? isolate()->function_without_prototype_map()
+ : isolate()->strict_mode_function_without_prototype_map();
CALL_HEAP_FUNCTION(isolate(),
isolate()->heap()->AllocateFunction(
*map,
@@ -1089,8 +1089,9 @@
Handle<JSFunction> Factory::NewFunctionWithoutPrototype(
Handle<String> name,
- StrictModeFlag strict_mode) {
- Handle<JSFunction> fun = NewFunctionWithoutPrototypeHelper(name,
strict_mode);
+ LanguageMode language_mode) {
+ Handle<JSFunction> fun =
+ NewFunctionWithoutPrototypeHelper(name, language_mode);
fun->set_context(isolate()->context()->global_context());
return fun;
}
=======================================
--- /branches/bleeding_edge/src/factory.h Mon Nov 21 02:18:47 2011
+++ /branches/bleeding_edge/src/factory.h Thu Nov 24 07:17:04 2011
@@ -279,7 +279,7 @@
Handle<JSFunction> NewFunctionWithoutPrototype(
Handle<String> name,
- StrictModeFlag strict_mode);
+ LanguageMode language_mode);
Handle<JSFunction> NewFunction(Handle<Object> super, bool is_global);
@@ -469,7 +469,7 @@
Handle<JSFunction> NewFunctionWithoutPrototypeHelper(
Handle<String> name,
- StrictModeFlag strict_mode);
+ LanguageMode language_mode);
Handle<DescriptorArray> CopyAppendCallbackDescriptors(
Handle<DescriptorArray> array,
=======================================
--- /branches/bleeding_edge/src/flag-definitions.h Fri Nov 18 06:08:57 2011
+++ /branches/bleeding_edge/src/flag-definitions.h Thu Nov 24 07:17:04 2011
@@ -321,7 +321,6 @@
// parser.cc
DEFINE_bool(allow_natives_syntax, false, "allow natives syntax")
-DEFINE_bool(strict_mode, true, "allow strict mode directives")
// simulator-arm.cc and simulator-mips.cc
DEFINE_bool(trace_sim, false, "Trace simulator execution")
=======================================
--- /branches/bleeding_edge/src/full-codegen.cc Fri Nov 11 05:48:14 2011
+++ /branches/bleeding_edge/src/full-codegen.cc Thu Nov 24 07:17:04 2011
@@ -544,10 +544,10 @@
int FullCodeGenerator::DeclareGlobalsFlags() {
- ASSERT(DeclareGlobalsStrictModeFlag::is_valid(strict_mode_flag()));
+ ASSERT(DeclareGlobalsLanguageMode::is_valid(language_mode()));
return DeclareGlobalsEvalFlag::encode(is_eval()) |
- DeclareGlobalsStrictModeFlag::encode(strict_mode_flag()) |
- DeclareGlobalsNativeFlag::encode(is_native());
+ DeclareGlobalsNativeFlag::encode(is_native()) |
+ DeclareGlobalsLanguageMode::encode(language_mode());
}
=======================================
--- /branches/bleeding_edge/src/full-codegen.h Fri Nov 11 05:48:14 2011
+++ /branches/bleeding_edge/src/full-codegen.h Thu Nov 24 07:17:04 2011
@@ -529,11 +529,11 @@
Handle<Script> script() { return info_->script(); }
bool is_eval() { return info_->is_eval(); }
bool is_native() { return info_->is_native(); }
- bool is_strict_mode() {
- return strict_mode_flag() == kStrictMode;
- }
- StrictModeFlag strict_mode_flag() {
- return function()->strict_mode_flag();
+ bool is_classic_mode() {
+ return language_mode() == CLASSIC_MODE;
+ }
+ LanguageMode language_mode() {
+ return function()->language_mode();
}
FunctionLiteral* function() { return info_->function(); }
Scope* scope() { return scope_; }
=======================================
--- /branches/bleeding_edge/src/globals.h Fri Oct 28 02:10:29 2011
+++ /branches/bleeding_edge/src/globals.h Thu Nov 24 07:17:04 2011
@@ -361,7 +361,30 @@
//
-----------------------------------------------------------------------------
// Declarations for use in both the preparser and the rest of V8.
+// The different language modes that V8 implements. ES5 defines two
language
+// modes: an unrestricted mode respectively a strict mode which are
indicated by
+// CLASSIC_MODE respectively STRICT_MODE in the enum. The harmony spec
drafts
+// for the next ES standard specify a new third mode which is
called 'extended
+// mode'. The extended mode is only available if the harmony flag is set.
It is
+// based on the 'strict mode' and adds new functionality to it. This means
that
+// most of the semantics of these two modes coincide.
+//
+// In the current draft the term 'base code' is used to refer to code that
is
+// neither in strict nor extended mode. However, the more distinguishing
term
+// 'classic mode' is used in V8 instead to avoid mix-ups.
+
+enum LanguageMode {
+ CLASSIC_MODE,
+ STRICT_MODE,
+ EXTENDED_MODE
+};
+
+
// The Strict Mode (ECMA-262 5th edition, 4.2.2).
+//
+// This flag is used in the backend to represent the language mode. So far
+// there is no semantic difference between the strict and the extended
mode in
+// the backend, so both modes are represented by the kStrictMode value.
enum StrictModeFlag {
kNonStrictMode,
kStrictMode
=======================================
--- /branches/bleeding_edge/src/handles.h Wed Nov 9 06:18:30 2011
+++ /branches/bleeding_edge/src/handles.h Thu Nov 24 07:17:04 2011
@@ -224,12 +224,6 @@
Handle<Object> value,
PropertyAttributes attributes = NONE);
-Handle<Object> SetPropertyWithInterceptor(Handle<JSObject> object,
- Handle<String> key,
- Handle<Object> value,
- PropertyAttributes attributes,
- StrictModeFlag strict_mode);
-
MUST_USE_RESULT Handle<Object> SetElement(Handle<JSObject> object,
uint32_t index,
Handle<Object> value,
=======================================
--- /branches/bleeding_edge/src/heap.cc Wed Nov 23 05:31:26 2011
+++ /branches/bleeding_edge/src/heap.cc Thu Nov 24 07:17:04 2011
@@ -3381,7 +3381,7 @@
JSObject* boilerplate;
int arguments_object_size;
bool strict_mode_callee = callee->IsJSFunction() &&
-
JSFunction::cast(callee)->shared()->strict_mode();
+ !JSFunction::cast(callee)->shared()->is_classic_mode();
if (strict_mode_callee) {
boilerplate =
isolate()->context()->global_context()->
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.h Thu Nov 24 05:42:52
2011
+++ /branches/bleeding_edge/src/hydrogen-instructions.h Thu Nov 24 07:17:04
2011
@@ -3415,9 +3415,9 @@
HValue* global_object,
Handle<Object> name,
HValue* value,
- bool strict_mode)
+ StrictModeFlag strict_mode_flag)
: name_(name),
- strict_mode_(strict_mode) {
+ strict_mode_flag_(strict_mode_flag) {
SetOperandAt(0, context);
SetOperandAt(1, global_object);
SetOperandAt(2, value);
@@ -3429,7 +3429,7 @@
HValue* global_object() { return OperandAt(1); }
Handle<Object> name() const { return name_; }
HValue* value() { return OperandAt(2); }
- bool strict_mode() { return strict_mode_; }
+ StrictModeFlag strict_mode_flag() { return strict_mode_flag_; }
virtual void PrintDataTo(StringStream* stream);
@@ -3441,7 +3441,7 @@
private:
Handle<Object> name_;
- bool strict_mode_;
+ StrictModeFlag strict_mode_flag_;
};
@@ -3971,8 +3971,8 @@
HValue* object,
HValue* key,
HValue* value,
- bool strict_mode)
- : strict_mode_(strict_mode) {
+ StrictModeFlag strict_mode_flag)
+ : strict_mode_flag_(strict_mode_flag) {
SetOperandAt(0, object);
SetOperandAt(1, key);
SetOperandAt(2, value);
@@ -3984,7 +3984,7 @@
HValue* key() { return OperandAt(1); }
HValue* value() { return OperandAt(2); }
HValue* context() { return OperandAt(3); }
- bool strict_mode() { return strict_mode_; }
+ StrictModeFlag strict_mode_flag() { return strict_mode_flag_; }
virtual Representation RequiredInputRepresentation(int index) {
return Representation::Tagged();
@@ -3995,7 +3995,7 @@
DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric)
private:
- bool strict_mode_;
+ StrictModeFlag strict_mode_flag_;
};
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc Thu Nov 24 05:42:52 2011
+++ /branches/bleeding_edge/src/hydrogen.cc Thu Nov 24 07:17:04 2011
@@ -6866,7 +6866,7 @@
// If the function we are inlining is a strict mode function or a
// builtin function, pass undefined as the receiver for function
// calls (instead of the global receiver).
- if ((target->shared()->native() || function->strict_mode()) &&
+ if ((target->shared()->native() || !function->is_classic_mode()) &&
call_kind == CALL_AS_FUNCTION) {
inner->SetValueAt(0, undefined);
}
=======================================
--- /branches/bleeding_edge/src/hydrogen.h Thu Nov 17 05:57:55 2011
+++ /branches/bleeding_edge/src/hydrogen.h Thu Nov 24 07:17:04 2011
@@ -780,7 +780,8 @@
function_state()->ClearInlinedTestContext();
}
StrictModeFlag function_strict_mode_flag() {
- return function_state()->compilation_info()->strict_mode_flag();
+ return function_state()->compilation_info()->is_classic_mode()
+ ? kNonStrictMode : kStrictMode;
}
// Generators for inline runtime functions.
=======================================
--- /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc Mon Nov 21 05:27:44
2011
+++ /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc Thu Nov 24 07:17:04
2011
@@ -72,9 +72,9 @@
// Get the function info from the stack.
__ mov(edx, Operand(esp, 1 * kPointerSize));
- int map_index = strict_mode_ == kStrictMode
- ? Context::STRICT_MODE_FUNCTION_MAP_INDEX
- : Context::FUNCTION_MAP_INDEX;
+ int map_index = (language_mode_ == CLASSIC_MODE)
+ ? Context::FUNCTION_MAP_INDEX
+ : Context::STRICT_MODE_FUNCTION_MAP_INDEX;
// Compute the function map in the current global context and set that
// as the map of the allocated object.
=======================================
--- /branches/bleeding_edge/src/ia32/full-codegen-ia32.cc Mon Nov 21
05:27:44 2011
+++ /branches/bleeding_edge/src/ia32/full-codegen-ia32.cc Thu Nov 24
07:17:04 2011
@@ -133,7 +133,7 @@
// with undefined when called as functions (without an explicit
// receiver object). ecx is zero for method calls and non-zero for
// function calls.
- if (info->is_strict_mode() || info->is_native()) {
+ if (!info->is_classic_mode() || info->is_native()) {
Label ok;
__ test(ecx, ecx);
__ j(zero, &ok, Label::kNear);
@@ -232,7 +232,7 @@
// The stub will rewrite receiver and parameter count if the previous
// stack frame was an arguments adapter frame.
ArgumentsAccessStub::Type type;
- if (is_strict_mode()) {
+ if (!is_classic_mode()) {
type = ArgumentsAccessStub::NEW_STRICT;
} else if (function()->has_duplicate_parameters()) {
type = ArgumentsAccessStub::NEW_NON_STRICT_SLOW;
@@ -1071,7 +1071,7 @@
!pretenure &&
scope()->is_function_scope() &&
info->num_literals() == 0) {
- FastNewClosureStub stub(info->strict_mode_flag());
+ FastNewClosureStub stub(info->language_mode());
__ push(Immediate(info));
__ CallStub(&stub);
} else {
@@ -1426,9 +1426,9 @@
VisitForAccumulatorValue(value);
__ mov(ecx, Immediate(key->handle()));
__ mov(edx, Operand(esp, 0));
- Handle<Code> ic = is_strict_mode()
- ? isolate()->builtins()->StoreIC_Initialize_Strict()
- : isolate()->builtins()->StoreIC_Initialize();
+ Handle<Code> ic = is_classic_mode()
+ ? isolate()->builtins()->StoreIC_Initialize()
+ : isolate()->builtins()->StoreIC_Initialize_Strict();
__ call(ic, RelocInfo::CODE_TARGET, key->id());
PrepareForBailoutForId(key->id(), NO_REGISTERS);
} else {
@@ -1829,9 +1829,9 @@
__ mov(edx, eax);
__ pop(eax); // Restore value.
__ mov(ecx, prop->key()->AsLiteral()->handle());
- Handle<Code> ic = is_strict_mode()
- ? isolate()->builtins()->StoreIC_Initialize_Strict()
- : isolate()->builtins()->StoreIC_Initialize();
+ Handle<Code> ic = is_classic_mode()
+ ? isolate()->builtins()->StoreIC_Initialize()
+ : isolate()->builtins()->StoreIC_Initialize_Strict();
__ call(ic);
break;
}
@@ -1842,9 +1842,9 @@
__ mov(ecx, eax);
__ pop(edx);
__ pop(eax); // Restore value.
- Handle<Code> ic = is_strict_mode()
- ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict()
- : isolate()->builtins()->KeyedStoreIC_Initialize();
+ Handle<Code> ic = is_classic_mode()
+ ? isolate()->builtins()->KeyedStoreIC_Initialize()
+ : isolate()->builtins()->KeyedStoreIC_Initialize_Strict();
__ call(ic);
break;
}
@@ -1860,9 +1860,9 @@
// Global var, const, or let.
__ mov(ecx, var->name());
__ mov(edx, GlobalObjectOperand());
- Handle<Code> ic = is_strict_mode()
- ? isolate()->builtins()->StoreIC_Initialize_Strict()
- : isolate()->builtins()->StoreIC_Initialize();
+ Handle<Code> ic = is_classic_mode()
+ ? isolate()->builtins()->StoreIC_Initialize()
+ : isolate()->builtins()->StoreIC_Initialize_Strict();
__ call(ic, RelocInfo::CODE_TARGET_CONTEXT);
} else if (op == Token::INIT_CONST) {
@@ -1894,7 +1894,7 @@
__ push(eax); // Value.
__ push(esi); // Context.
__ push(Immediate(var->name()));
- __ push(Immediate(Smi::FromInt(strict_mode_flag())));
+ __ push(Immediate(Smi::FromInt(language_mode())));
__ CallRuntime(Runtime::kStoreContextSlot, 4);
} else {
ASSERT(var->IsStackAllocated() || var->IsContextSlot());
@@ -1937,7 +1937,7 @@
__ push(eax); // Value.
__ push(esi); // Context.
__ push(Immediate(var->name()));
- __ push(Immediate(Smi::FromInt(strict_mode_flag())));
+ __ push(Immediate(Smi::FromInt(language_mode())));
__ CallRuntime(Runtime::kStoreContextSlot, 4);
}
}
@@ -1969,9 +1969,9 @@
} else {
__ pop(edx);
}
- Handle<Code> ic = is_strict_mode()
- ? isolate()->builtins()->StoreIC_Initialize_Strict()
- : isolate()->builtins()->StoreIC_Initialize();
+ Handle<Code> ic = is_classic_mode()
+ ? isolate()->builtins()->StoreIC_Initialize()
+ : isolate()->builtins()->StoreIC_Initialize_Strict();
__ call(ic, RelocInfo::CODE_TARGET, expr->id());
// If the assignment ends an initialization block, revert to fast case.
@@ -2009,9 +2009,9 @@
}
// Record source code position before IC call.
SetSourcePosition(expr->position());
- Handle<Code> ic = is_strict_mode()
- ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict()
- : isolate()->builtins()->KeyedStoreIC_Initialize();
+ Handle<Code> ic = is_classic_mode()
+ ? isolate()->builtins()->KeyedStoreIC_Initialize()
+ : isolate()->builtins()->KeyedStoreIC_Initialize_Strict();
__ call(ic, RelocInfo::CODE_TARGET, expr->id());
// If the assignment ends an initialization block, revert to fast case.
@@ -2154,16 +2154,13 @@
// Push the receiver of the enclosing function.
__ push(Operand(ebp, (2 + info_->scope()->num_parameters()) *
kPointerSize));
-
- // Push the strict mode flag. In harmony mode every eval call
- // is a strict mode eval call.
- StrictModeFlag strict_mode =
- FLAG_harmony_scoping ? kStrictMode : strict_mode_flag();
- __ push(Immediate(Smi::FromInt(strict_mode)));
+ // Push the language mode.
+ __ push(Immediate(Smi::FromInt(language_mode())));
// Push the start position of the scope the calls resides in.
__ push(Immediate(Smi::FromInt(scope()->start_position())));
+ // Do the runtime call.
__ CallRuntime(Runtime::kResolvePossiblyDirectEval, 5);
}
@@ -3688,14 +3685,16 @@
if (property != NULL) {
VisitForStackValue(property->obj());
VisitForStackValue(property->key());
- __ push(Immediate(Smi::FromInt(strict_mode_flag())));
+ StrictModeFlag strict_mode_flag = (language_mode() == CLASSIC_MODE)
+ ? kNonStrictMode : kStrictMode;
+ __ push(Immediate(Smi::FromInt(strict_mode_flag)));
__ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
context()->Plug(eax);
} else if (proxy != NULL) {
Variable* var = proxy->var();
// Delete of an unqualified identifier is disallowed in strict mode
// but "delete this" is allowed.
- ASSERT(strict_mode_flag() == kNonStrictMode || var->is_this());
+ ASSERT(language_mode() == CLASSIC_MODE || var->is_this());
if (var->IsUnallocated()) {
__ push(GlobalObjectOperand());
__ push(Immediate(var->name()));
@@ -3974,9 +3973,9 @@
case NAMED_PROPERTY: {
__ mov(ecx, prop->key()->AsLiteral()->handle());
__ pop(edx);
- Handle<Code> ic = is_strict_mode()
- ? isolate()->builtins()->StoreIC_Initialize_Strict()
- : isolate()->builtins()->StoreIC_Initialize();
+ Handle<Code> ic = is_classic_mode()
+ ? isolate()->builtins()->StoreIC_Initialize()
+ : isolate()->builtins()->StoreIC_Initialize_Strict();
__ call(ic, RelocInfo::CODE_TARGET, expr->id());
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
if (expr->is_postfix()) {
@@ -3991,9 +3990,9 @@
case KEYED_PROPERTY: {
__ pop(ecx);
__ pop(edx);
- Handle<Code> ic = is_strict_mode()
- ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict()
- : isolate()->builtins()->KeyedStoreIC_Initialize();
+ Handle<Code> ic = is_classic_mode()
+ ? isolate()->builtins()->KeyedStoreIC_Initialize()
+ : isolate()->builtins()->KeyedStoreIC_Initialize_Strict();
__ call(ic, RelocInfo::CODE_TARGET, expr->id());
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
if (expr->is_postfix()) {
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Thu Nov 24
05:42:52 2011
+++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Thu Nov 24
07:17:04 2011
@@ -145,7 +145,7 @@
// with undefined when called as functions (without an explicit
// receiver object). ecx is zero for method calls and non-zero for
// function calls.
- if (info_->is_strict_mode() || info_->is_native()) {
+ if (!info_->is_classic_mode() || info_->is_native()) {
Label ok;
__ test(ecx, Operand(ecx));
__ j(zero, &ok, Label::kNear);
@@ -2160,7 +2160,7 @@
ASSERT(ToRegister(instr->value()).is(eax));
__ mov(ecx, instr->name());
- Handle<Code> ic = instr->strict_mode()
+ Handle<Code> ic = (instr->strict_mode_flag() == kStrictMode)
? isolate()->builtins()->StoreIC_Initialize_Strict()
: isolate()->builtins()->StoreIC_Initialize();
CallCode(ic, RelocInfo::CODE_TARGET_CONTEXT, instr);
@@ -3220,7 +3220,7 @@
ASSERT(ToRegister(instr->value()).is(eax));
__ mov(ecx, instr->name());
- Handle<Code> ic = instr->strict_mode()
+ Handle<Code> ic = (instr->strict_mode_flag() == kStrictMode)
? isolate()->builtins()->StoreIC_Initialize_Strict()
: isolate()->builtins()->StoreIC_Initialize();
CallCode(ic, RelocInfo::CODE_TARGET, instr);
@@ -3352,7 +3352,7 @@
ASSERT(ToRegister(instr->key()).is(ecx));
ASSERT(ToRegister(instr->value()).is(eax));
- Handle<Code> ic = instr->strict_mode()
+ Handle<Code> ic = (instr->strict_mode_flag() == kStrictMode)
? isolate()->builtins()->KeyedStoreIC_Initialize_Strict()
: isolate()->builtins()->KeyedStoreIC_Initialize();
CallCode(ic, RelocInfo::CODE_TARGET, instr);
@@ -4333,7 +4333,7 @@
Handle<SharedFunctionInfo> shared_info = instr->shared_info();
bool pretenure = instr->hydrogen()->pretenure();
if (!pretenure && shared_info->num_literals() == 0) {
- FastNewClosureStub stub(shared_info->strict_mode_flag());
+ FastNewClosureStub stub(shared_info->language_mode());
__ push(Immediate(shared_info));
CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
} else {
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.h Thu Nov 24
05:42:52 2011
+++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.h Thu Nov 24
07:17:04 2011
@@ -132,7 +132,7 @@
bool is_aborted() const { return status_ == ABORTED; }
StrictModeFlag strict_mode_flag() const {
- return info()->strict_mode_flag();
+ return info()->is_classic_mode() ? kNonStrictMode : kStrictMode;
}
bool dynamic_frame_alignment() const { return dynamic_frame_alignment_; }
void set_dynamic_frame_alignment(bool value) {
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.h Thu Nov 24 05:42:52 2011
+++ /branches/bleeding_edge/src/ia32/lithium-ia32.h Thu Nov 24 07:17:04 2011
@@ -1280,7 +1280,7 @@
LOperand* global_object() { return InputAt(1); }
Handle<Object> name() const { return hydrogen()->name(); }
LOperand* value() { return InputAt(2); }
- bool strict_mode() { return hydrogen()->strict_mode(); }
+ StrictModeFlag strict_mode_flag() { return
hydrogen()->strict_mode_flag(); }
};
@@ -1661,7 +1661,6 @@
LOperand* value() { return inputs_[2]; }
Handle<Object> name() const { return hydrogen()->name(); }
StrictModeFlag strict_mode_flag() { return
hydrogen()->strict_mode_flag(); }
- bool strict_mode() { return strict_mode_flag() == kStrictMode; }
};
@@ -1751,7 +1750,7 @@
LOperand* object() { return inputs_[1]; }
LOperand* key() { return inputs_[2]; }
LOperand* value() { return inputs_[3]; }
- bool strict_mode() { return hydrogen()->strict_mode(); }
+ StrictModeFlag strict_mode_flag() { return
hydrogen()->strict_mode_flag(); }
};
=======================================
--- /branches/bleeding_edge/src/ia32/stub-cache-ia32.cc Wed Nov 9 06:32:51
2011
+++ /branches/bleeding_edge/src/ia32/stub-cache-ia32.cc Thu Nov 24 07:17:04
2011
@@ -2169,7 +2169,7 @@
break;
case STRING_CHECK:
- if (function->IsBuiltin() || function->shared()->strict_mode()) {
+ if (function->IsBuiltin() || !function->shared()->is_classic_mode())
{
// Check that the object is a string or a symbol.
__ CmpObjectType(edx, FIRST_NONSTRING_TYPE, eax);
__ j(above_equal, &miss);
@@ -2187,7 +2187,7 @@
break;
case NUMBER_CHECK:
- if (function->IsBuiltin() || function->shared()->strict_mode()) {
+ if (function->IsBuiltin() || !function->shared()->is_classic_mode())
{
Label fast;
// Check that the object is a smi or a heap number.
__ JumpIfSmi(edx, &fast);
@@ -2208,7 +2208,7 @@
break;
case BOOLEAN_CHECK:
- if (function->IsBuiltin() || function->shared()->strict_mode()) {
+ if (function->IsBuiltin() || !function->shared()->is_classic_mode())
{
Label fast;
// Check that the object is a boolean.
__ cmp(edx, factory()->true_value());
=======================================
--- /branches/bleeding_edge/src/ic.cc Tue Nov 8 00:42:13 2011
+++ /branches/bleeding_edge/src/ic.cc Thu Nov 24 07:17:04 2011
@@ -435,7 +435,7 @@
if (callee->IsJSFunction()) {
Handle<JSFunction> function = Handle<JSFunction>::cast(callee);
- if (function->shared()->strict_mode() || function->IsBuiltin()) {
+ if (!function->shared()->is_classic_mode() || function->IsBuiltin()) {
// Do not wrap receiver for strict mode functions or for builtins.
return;
}
=======================================
--- /branches/bleeding_edge/src/mips/code-stubs-mips.cc Mon Nov 21 06:05:18
2011
+++ /branches/bleeding_edge/src/mips/code-stubs-mips.cc Thu Nov 24 07:17:04
2011
@@ -100,9 +100,9 @@
&gc,
TAG_OBJECT);
- int map_index = strict_mode_ == kStrictMode
- ? Context::STRICT_MODE_FUNCTION_MAP_INDEX
- : Context::FUNCTION_MAP_INDEX;
+ int map_index = (language_mode_ == CLASSIC_MODE)
+ ? Context::FUNCTION_MAP_INDEX
+ : Context::STRICT_MODE_FUNCTION_MAP_INDEX;
// Compute the function map in the current global context and set that
// as the map of the allocated object.
=======================================
--- /branches/bleeding_edge/src/mips/full-codegen-mips.cc Mon Nov 21
06:05:18 2011
+++ /branches/bleeding_edge/src/mips/full-codegen-mips.cc Thu Nov 24
07:17:04 2011
@@ -153,7 +153,7 @@
// with undefined when called as functions (without an explicit
// receiver object). t1 is zero for method calls and non-zero for
// function calls.
- if (info->is_strict_mode() || info->is_native()) {
+ if (!info->is_classic_mode() || info->is_native()) {
Label ok;
__ Branch(&ok, eq, t1, Operand(zero_reg));
int receiver_offset = info->scope()->num_parameters() * kPointerSize;
@@ -245,7 +245,7 @@
// The stub will rewrite receiever and parameter count if the previous
// stack frame was an arguments adapter frame.
ArgumentsAccessStub::Type type;
- if (is_strict_mode()) {
+ if (!is_classic_mode()) {
type = ArgumentsAccessStub::NEW_STRICT;
} else if (function()->has_duplicate_parameters()) {
type = ArgumentsAccessStub::NEW_NON_STRICT_SLOW;
@@ -1124,7 +1124,7 @@
!pretenure &&
scope()->is_function_scope() &&
info->num_literals() == 0) {
- FastNewClosureStub stub(info->strict_mode_flag());
+ FastNewClosureStub stub(info->language_mode());
__ li(a0, Operand(info));
__ push(a0);
__ CallStub(&stub);
@@ -1474,9 +1474,9 @@
__ mov(a0, result_register());
__ li(a2, Operand(key->handle()));
__ lw(a1, MemOperand(sp));
- Handle<Code> ic = is_strict_mode()
- ? isolate()->builtins()->StoreIC_Initialize_Strict()
- : isolate()->builtins()->StoreIC_Initialize();
+ Handle<Code> ic = is_classic_mode()
+ ? isolate()->builtins()->StoreIC_Initialize()
+ : isolate()->builtins()->StoreIC_Initialize_Strict();
__ Call(ic, RelocInfo::CODE_TARGET, key->id());
PrepareForBailoutForId(key->id(), NO_REGISTERS);
} else {
@@ -1613,7 +1613,9 @@
__ push(t6); // Copy of array literal.
__ li(a1, Operand(Smi::FromInt(i)));
__ li(a2, Operand(Smi::FromInt(NONE))); // PropertyAttributes
- __ li(a3, Operand(Smi::FromInt(strict_mode_flag()))); // Strict mode.
+ StrictModeFlag strict_mode_flag = (language_mode() == CLASSIC_MODE)
+ ? kNonStrictMode : kStrictMode;
+ __ li(a3, Operand(Smi::FromInt(strict_mode_flag))); // Strict mode.
__ Push(a1, result_register(), a2, a3);
__ CallRuntime(Runtime::kSetProperty, 5);
__ Branch(&element_done);
@@ -1933,9 +1935,9 @@
__ mov(a1, result_register());
__ pop(a0); // Restore value.
__ li(a2, Operand(prop->key()->AsLiteral()->handle()));
- Handle<Code> ic = is_strict_mode()
- ? isolate()->builtins()->StoreIC_Initialize_Strict()
- : isolate()->builtins()->StoreIC_Initialize();
+ Handle<Code> ic = is_classic_mode()
+ ? isolate()->builtins()->StoreIC_Initialize()
+ : isolate()->builtins()->StoreIC_Initialize_Strict();
__ Call(ic);
break;
}
@@ -1946,9 +1948,9 @@
__ mov(a1, result_register());
__ pop(a2);
__ pop(a0); // Restore value.
- Handle<Code> ic = is_strict_mode()
- ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict()
- : isolate()->builtins()->KeyedStoreIC_Initialize();
+ Handle<Code> ic = is_classic_mode()
+ ? isolate()->builtins()->KeyedStoreIC_Initialize()
+ : isolate()->builtins()->KeyedStoreIC_Initialize_Strict();
__ Call(ic);
break;
}
@@ -1965,9 +1967,9 @@
__ mov(a0, result_register());
__ li(a2, Operand(var->name()));
__ lw(a1, GlobalObjectOperand());
- Handle<Code> ic = is_strict_mode()
- ? isolate()->builtins()->StoreIC_Initialize_Strict()
- : isolate()->builtins()->StoreIC_Initialize();
+ Handle<Code> ic = is_classic_mode()
+ ? isolate()->builtins()->StoreIC_Initialize()
+ : isolate()->builtins()->StoreIC_Initialize_Strict();
__ Call(ic, RelocInfo::CODE_TARGET_CONTEXT);
} else if (op == Token::INIT_CONST) {
@@ -1998,7 +2000,7 @@
if (var->IsLookupSlot()) {
__ push(v0); // Value.
__ li(a1, Operand(var->name()));
- __ li(a0, Operand(Smi::FromInt(strict_mode_flag())));
+ __ li(a0, Operand(Smi::FromInt(language_mode())));
__ Push(cp, a1, a0); // Context, name, strict mode.
__ CallRuntime(Runtime::kStoreContextSlot, 4);
} else {
@@ -2046,7 +2048,7 @@
ASSERT(var->IsLookupSlot());
__ push(v0); // Value.
__ li(a1, Operand(var->name()));
- __ li(a0, Operand(Smi::FromInt(strict_mode_flag())));
+ __ li(a0, Operand(Smi::FromInt(language_mode())));
__ Push(cp, a1, a0); // Context, name, strict mode.
__ CallRuntime(Runtime::kStoreContextSlot, 4);
}
@@ -2084,9 +2086,9 @@
__ pop(a1);
}
- Handle<Code> ic = is_strict_mode()
- ? isolate()->builtins()->StoreIC_Initialize_Strict()
- : isolate()->builtins()->StoreIC_Initialize();
+ Handle<Code> ic = is_classic_mode()
+ ? isolate()->builtins()->StoreIC_Initialize()
+ : isolate()->builtins()->StoreIC_Initialize_Strict();
__ Call(ic, RelocInfo::CODE_TARGET, expr->id());
// If the assignment ends an initialization block, revert to fast case.
@@ -2136,9 +2138,9 @@
__ pop(a2);
}
- Handle<Code> ic = is_strict_mode()
- ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict()
- : isolate()->builtins()->KeyedStoreIC_Initialize();
+ Handle<Code> ic = is_classic_mode()
+ ? isolate()->builtins()->KeyedStoreIC_Initialize()
+ : isolate()->builtins()->KeyedStoreIC_Initialize_Strict();
__ Call(ic, RelocInfo::CODE_TARGET, expr->id());
// If the assignment ends an initialization block, revert to fast case.
@@ -2262,21 +2264,19 @@
}
__ push(a1);
- // Push the receiver of the enclosing function and do runtime call.
+ // Push the receiver of the enclosing function.
int receiver_offset = 2 + info_->scope()->num_parameters();
__ lw(a1, MemOperand(fp, receiver_offset * kPointerSize));
__ push(a1);
- // Push the strict mode flag. In harmony mode every eval call
- // is a strict mode eval call.
- StrictModeFlag strict_mode =
- FLAG_harmony_scoping ? kStrictMode : strict_mode_flag();
- __ li(a1, Operand(Smi::FromInt(strict_mode)));
+ // Push the language mode.
+ __ li(a1, Operand(Smi::FromInt(language_mode())));
__ push(a1);
// Push the start position of the scope the calls resides in.
__ li(a1, Operand(Smi::FromInt(scope()->start_position())));
__ push(a1);
+ // Do the runtime call.
__ CallRuntime(Runtime::kResolvePossiblyDirectEval, 5);
}
@@ -3784,7 +3784,9 @@
if (property != NULL) {
VisitForStackValue(property->obj());
VisitForStackValue(property->key());
- __ li(a1, Operand(Smi::FromInt(strict_mode_flag())));
+ StrictModeFlag strict_mode_flag = (language_mode() == CLASSIC_MODE)
+ ? kNonStrictMode : kStrictMode;
+ __ li(a1, Operand(Smi::FromInt(strict_mode_flag)));
__ push(a1);
__ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
context()->Plug(v0);
@@ -3792,7 +3794,7 @@
Variable* var = proxy->var();
// Delete of an unqualified identifier is disallowed in strict mode
// but "delete this" is allowed.
- ASSERT(strict_mode_flag() == kNonStrictMode || var->is_this());
+ ASSERT(language_mode() == CLASSIC_MODE || var->is_this());
if (var->IsUnallocated()) {
__ lw(a2, GlobalObjectOperand());
__ li(a1, Operand(var->name()));
@@ -4058,9 +4060,9 @@
__ mov(a0, result_register()); // Value.
__ li(a2, Operand(prop->key()->AsLiteral()->handle())); // Name.
__ pop(a1); // Receiver.
- Handle<Code> ic = is_strict_mode()
- ? isolate()->builtins()->StoreIC_Initialize_Strict()
- : isolate()->builtins()->StoreIC_Initialize();
+ Handle<Code> ic = is_classic_mode()
+ ? isolate()->builtins()->StoreIC_Initialize()
+ : isolate()->builtins()->StoreIC_Initialize_Strict();
__ Call(ic, RelocInfo::CODE_TARGET, expr->id());
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
if (expr->is_postfix()) {
@@ -4076,9 +4078,9 @@
__ mov(a0, result_register()); // Value.
__ pop(a1); // Key.
__ pop(a2); // Receiver.
- Handle<Code> ic = is_strict_mode()
- ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict()
- : isolate()->builtins()->KeyedStoreIC_Initialize();
+ Handle<Code> ic = is_classic_mode()
+ ? isolate()->builtins()->KeyedStoreIC_Initialize()
+ : isolate()->builtins()->KeyedStoreIC_Initialize_Strict();
__ Call(ic, RelocInfo::CODE_TARGET, expr->id());
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
if (expr->is_postfix()) {
=======================================
--- /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Tue Nov 22
05:51:56 2011
+++ /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Thu Nov 24
07:17:04 2011
@@ -141,7 +141,7 @@
// with undefined when called as functions (without an explicit
// receiver object). r5 is zero for method calls and non-zero for
// function calls.
- if (info_->is_strict_mode() || info_->is_native()) {
+ if (!info_->is_classic_mode() || info_->is_native()) {
Label ok;
__ Branch(&ok, eq, t1, Operand(zero_reg));
@@ -2164,7 +2164,7 @@
ASSERT(ToRegister(instr->value()).is(a0));
__ li(a2, Operand(instr->name()));
- Handle<Code> ic = instr->strict_mode()
+ Handle<Code> ic = (instr->strict_mode_flag() == kStrictMode)
? isolate()->builtins()->StoreIC_Initialize_Strict()
: isolate()->builtins()->StoreIC_Initialize();
CallCode(ic, RelocInfo::CODE_TARGET_CONTEXT, instr);
@@ -3258,7 +3258,7 @@
// Name is always in a2.
__ li(a2, Operand(instr->name()));
- Handle<Code> ic = instr->strict_mode()
+ Handle<Code> ic = (instr->strict_mode_flag() == kStrictMode)
? isolate()->builtins()->StoreIC_Initialize_Strict()
: isolate()->builtins()->StoreIC_Initialize();
CallCode(ic, RelocInfo::CODE_TARGET, instr);
@@ -3439,7 +3439,7 @@
ASSERT(ToRegister(instr->key()).is(a1));
ASSERT(ToRegister(instr->value()).is(a0));
- Handle<Code> ic = instr->strict_mode()
+ Handle<Code> ic = (instr->strict_mode_flag() == kStrictMode)
? isolate()->builtins()->KeyedStoreIC_Initialize_Strict()
: isolate()->builtins()->KeyedStoreIC_Initialize();
CallCode(ic, RelocInfo::CODE_TARGET, instr);
@@ -4325,7 +4325,7 @@
Handle<SharedFunctionInfo> shared_info = instr->shared_info();
bool pretenure = instr->hydrogen()->pretenure();
if (!pretenure && shared_info->num_literals() == 0) {
- FastNewClosureStub stub(shared_info->strict_mode_flag());
+ FastNewClosureStub stub(shared_info->language_mode());
__ li(a1, Operand(shared_info));
__ push(a1);
CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
=======================================
--- /branches/bleeding_edge/src/mips/lithium-codegen-mips.h Tue Nov 22
05:51:56 2011
+++ /branches/bleeding_edge/src/mips/lithium-codegen-mips.h Thu Nov 24
07:17:04 2011
@@ -138,7 +138,7 @@
bool is_aborted() const { return status_ == ABORTED; }
StrictModeFlag strict_mode_flag() const {
- return info()->strict_mode_flag();
+ return info()->is_classic_mode() ? kNonStrictMode : kStrictMode;
}
LChunk* chunk() const { return chunk_; }
=======================================
--- /branches/bleeding_edge/src/mips/lithium-mips.h Tue Nov 22 05:51:56 2011
+++ /branches/bleeding_edge/src/mips/lithium-mips.h Thu Nov 24 07:17:04 2011
@@ -1258,7 +1258,7 @@
LOperand* global_object() { return InputAt(0); }
Handle<Object> name() const { return hydrogen()->name(); }
LOperand* value() { return InputAt(1); }
- bool strict_mode() { return hydrogen()->strict_mode(); }
+ StrictModeFlag strict_mode_flag() { return
hydrogen()->strict_mode_flag(); }
};
@@ -1618,7 +1618,6 @@
LOperand* value() { return inputs_[1]; }
Handle<Object> name() const { return hydrogen()->name(); }
StrictModeFlag strict_mode_flag() { return
hydrogen()->strict_mode_flag(); }
- bool strict_mode() { return strict_mode_flag() == kStrictMode; }
};
@@ -1680,7 +1679,7 @@
LOperand* object() { return inputs_[0]; }
LOperand* key() { return inputs_[1]; }
LOperand* value() { return inputs_[2]; }
- bool strict_mode() { return hydrogen()->strict_mode(); }
+ StrictModeFlag strict_mode_flag() { return
hydrogen()->strict_mode_flag(); }
};
class LStoreKeyedSpecializedArrayElement: public LTemplateInstruction<0,
3, 0> {
=======================================
--- /branches/bleeding_edge/src/mips/stub-cache-mips.cc Thu Nov 10 00:07:39
2011
+++ /branches/bleeding_edge/src/mips/stub-cache-mips.cc Thu Nov 24 07:17:04
2011
@@ -2282,7 +2282,7 @@
break;
case STRING_CHECK:
- if (function->IsBuiltin() || function->shared()->strict_mode()) {
+ if (function->IsBuiltin() || !function->shared()->is_classic_mode())
{
// Check that the object is a two-byte string or a symbol.
__ GetObjectType(a1, a3, a3);
__ Branch(&miss, Ugreater_equal, a3,
Operand(FIRST_NONSTRING_TYPE));
@@ -2300,7 +2300,7 @@
break;
case NUMBER_CHECK:
- if (function->IsBuiltin() || function->shared()->strict_mode()) {
+ if (function->IsBuiltin() || !function->shared()->is_classic_mode())
{
Label fast;
// Check that the object is a smi or a heap number.
__ JumpIfSmi(a1, &fast);
@@ -2321,7 +2321,7 @@
break;
case BOOLEAN_CHECK:
- if (function->IsBuiltin() || function->shared()->strict_mode()) {
+ if (function->IsBuiltin() || !function->shared()->is_classic_mode())
{
Label fast;
// Check that the object is a boolean.
__ LoadRoot(t0, Heap::kTrueValueRootIndex);
=======================================
--- /branches/bleeding_edge/src/objects-inl.h Wed Nov 23 05:08:28 2011
+++ /branches/bleeding_edge/src/objects-inl.h Thu Nov 24 07:17:04 2011
@@ -3542,23 +3542,39 @@
}
-StrictModeFlag SharedFunctionInfo::strict_mode_flag() {
- return BooleanBit::get(compiler_hints(), kStrictModeFunction)
- ? kStrictMode : kNonStrictMode;
+LanguageMode SharedFunctionInfo::language_mode() {
+ int hints = compiler_hints();
+ if (BooleanBit::get(hints, kExtendedModeFunction)) {
+ ASSERT(BooleanBit::get(hints, kStrictModeFunction));
+ return EXTENDED_MODE;
+ }
+ return BooleanBit::get(hints, kStrictModeFunction)
+ ? STRICT_MODE : CLASSIC_MODE;
}
-void SharedFunctionInfo::set_strict_mode_flag(StrictModeFlag
strict_mode_flag) {
- ASSERT(strict_mode_flag == kStrictMode ||
- strict_mode_flag == kNonStrictMode);
- bool value = strict_mode_flag == kStrictMode;
- set_compiler_hints(
- BooleanBit::set(compiler_hints(), kStrictModeFunction, value));
+void SharedFunctionInfo::set_language_mode(LanguageMode language_mode) {
+ // We only allow language mode transitions that go set the same language
mode
+ // again or go up in the chain:
+ // CLASSIC_MODE -> STRICT_MODE -> EXTENDED_MODE.
+ ASSERT(this->language_mode() == CLASSIC_MODE ||
+ this->language_mode() == language_mode ||
+ language_mode == EXTENDED_MODE);
+ int hints = compiler_hints();
+ hints = BooleanBit::set(
+ hints, kStrictModeFunction, language_mode != CLASSIC_MODE);
+ hints = BooleanBit::set(
+ hints, kExtendedModeFunction, language_mode == EXTENDED_MODE);
+ set_compiler_hints(hints);
}
-BOOL_GETTER(SharedFunctionInfo, compiler_hints, strict_mode,
- kStrictModeFunction)
+bool SharedFunctionInfo::is_classic_mode() {
+ return !BooleanBit::get(compiler_hints(), kStrictModeFunction);
+}
+
+BOOL_GETTER(SharedFunctionInfo, compiler_hints, is_extended_mode,
+ kExtendedModeFunction)
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, native, kNative)
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints,
name_should_print_as_anonymous,
=======================================
--- /branches/bleeding_edge/src/objects.cc Wed Nov 23 05:08:28 2011
+++ /branches/bleeding_edge/src/objects.cc Thu Nov 24 07:17:04 2011
@@ -7225,18 +7225,18 @@
Object* JSFunction::RemovePrototype() {
Context* global_context = context()->global_context();
- Map* no_prototype_map = shared()->strict_mode()
- ? global_context->strict_mode_function_without_prototype_map()
- : global_context->function_without_prototype_map();
+ Map* no_prototype_map = shared()->is_classic_mode()
+ ? global_context->function_without_prototype_map()
+ : global_context->strict_mode_function_without_prototype_map();
if (map() == no_prototype_map) {
// Be idempotent.
return this;
}
- ASSERT(!shared()->strict_mode() ||
- map() == global_context->strict_mode_function_map());
- ASSERT(shared()->strict_mode() || map() ==
global_context->function_map());
+ ASSERT(map() == (shared()->is_classic_mode()
+ ? global_context->function_map()
+ : global_context->strict_mode_function_map()));
set_map(no_prototype_map);
set_prototype_or_initial_map(no_prototype_map->GetHeap()->the_hole_value());
@@ -10269,11 +10269,11 @@
public:
StringSharedKey(String* source,
SharedFunctionInfo* shared,
- StrictModeFlag strict_mode,
+ LanguageMode language_mode,
int scope_position)
: source_(source),
shared_(shared),
- strict_mode_(strict_mode),
+ language_mode_(language_mode),
scope_position_(scope_position) { }
bool IsMatch(Object* other) {
@@ -10281,11 +10281,12 @@
FixedArray* other_array = FixedArray::cast(other);
SharedFunctionInfo* shared =
SharedFunctionInfo::cast(other_array->get(0));
if (shared != shared_) return false;
- int strict_unchecked = Smi::cast(other_array->get(2))->value();
- ASSERT(strict_unchecked == kStrictMode ||
- strict_unchecked == kNonStrictMode);
- StrictModeFlag strict_mode =
static_cast<StrictModeFlag>(strict_unchecked);
- if (strict_mode != strict_mode_) return false;
+ int language_unchecked = Smi::cast(other_array->get(2))->value();
+ ASSERT(language_unchecked == CLASSIC_MODE ||
+ language_unchecked == STRICT_MODE ||
+ language_unchecked == EXTENDED_MODE);
+ LanguageMode language_mode =
static_cast<LanguageMode>(language_unchecked);
+ if (language_mode != language_mode_) return false;
int scope_position = Smi::cast(other_array->get(3))->value();
if (scope_position != scope_position_) return false;
String* source = String::cast(other_array->get(1));
@@ -10294,7 +10295,7 @@
static uint32_t StringSharedHashHelper(String* source,
SharedFunctionInfo* shared,
- StrictModeFlag strict_mode,
+ LanguageMode language_mode,
int scope_position) {
uint32_t hash = source->Hash();
if (shared->HasSourceCode()) {
@@ -10305,7 +10306,8 @@
// collection.
Script* script = Script::cast(shared->script());
hash ^= String::cast(script->source())->Hash();
- if (strict_mode == kStrictMode) hash ^= 0x8000;
+ if (language_mode == STRICT_MODE) hash ^= 0x8000;
+ if (language_mode == EXTENDED_MODE) hash ^= 0x0080;
hash += scope_position;
}
return hash;
@@ -10313,19 +10315,21 @@
uint32_t Hash() {
return StringSharedHashHelper(
- source_, shared_, strict_mode_, scope_position_);
+ source_, shared_, language_mode_, scope_position_);
}
uint32_t HashForObject(Object* obj) {
FixedArray* other_array = FixedArray::cast(obj);
SharedFunctionInfo* shared =
SharedFunctionInfo::cast(other_array->get(0));
String* source = String::cast(other_array->get(1));
- int strict_unchecked = Smi::cast(other_array->get(2))->value();
- ASSERT(strict_unchecked == kStrictMode ||
- strict_unchecked == kNonStrictMode);
- StrictModeFlag strict_mode =
static_cast<StrictModeFlag>(strict_unchecked);
+ int language_unchecked = Smi::cast(other_array->get(2))->value();
+ ASSERT(language_unchecked == CLASSIC_MODE ||
+ language_unchecked == STRICT_MODE ||
+ language_unchecked == EXTENDED_MODE);
+ LanguageMode language_mode =
static_cast<LanguageMode>(language_unchecked);
int scope_position = Smi::cast(other_array->get(3))->value();
- return StringSharedHashHelper(source, shared, strict_mode,
scope_position);
+ return StringSharedHashHelper(
+ source, shared, language_mode, scope_position);
}
MUST_USE_RESULT MaybeObject* AsObject() {
@@ -10336,7 +10340,7 @@
FixedArray* other_array = FixedArray::cast(obj);
other_array->set(0, shared_);
other_array->set(1, source_);
- other_array->set(2, Smi::FromInt(strict_mode_));
+ other_array->set(2, Smi::FromInt(language_mode_));
other_array->set(3, Smi::FromInt(scope_position_));
return other_array;
}
@@ -10344,7 +10348,7 @@
private:
String* source_;
SharedFunctionInfo* shared_;
- StrictModeFlag strict_mode_;
+ LanguageMode language_mode_;
int scope_position_;
};
@@ -11500,11 +11504,11 @@
Object* CompilationCacheTable::LookupEval(String* src,
Context* context,
- StrictModeFlag strict_mode,
+ LanguageMode language_mode,
int scope_position) {
StringSharedKey key(src,
context->closure()->shared(),
- strict_mode,
+ language_mode,
scope_position);
int entry = FindEntry(&key);
if (entry == kNotFound) return GetHeap()->undefined_value();
@@ -11544,7 +11548,7 @@
int scope_position) {
StringSharedKey key(src,
context->closure()->shared(),
- value->strict_mode_flag(),
+ value->language_mode(),
scope_position);
Object* obj;
{ MaybeObject* maybe_obj = EnsureCapacity(1, &key);
=======================================
--- /branches/bleeding_edge/src/objects.h Wed Nov 23 05:08:28 2011
+++ /branches/bleeding_edge/src/objects.h Thu Nov 24 07:17:04 2011
@@ -3091,12 +3091,12 @@
// Does this scope call eval?
bool CallsEval();
- // Is this scope a strict mode scope?
- bool IsStrictMode();
+ // Return the language mode of this scope.
+ LanguageMode language_mode();
// Does this scope make a non-strict eval call?
bool CallsNonStrictEval() {
- return CallsEval() && !IsStrictMode();
+ return CallsEval() && (language_mode() == CLASSIC_MODE);
}
// Return the total number of locals allocated on the stack and in the
@@ -3264,9 +3264,9 @@
// Properties of scopes.
class TypeField: public BitField<ScopeType, 0, 3>
{};
class CallsEvalField: public BitField<bool, 3, 1>
{};
- class StrictModeField: public BitField<bool, 4, 1>
{};
- class FunctionVariableField: public BitField<FunctionVariableInfo, 5, 2>
{};
- class FunctionVariableMode: public BitField<VariableMode, 7, 3>
{};
+ class LanguageModeField: public BitField<LanguageMode, 4, 2>
{};
+ class FunctionVariableField: public BitField<FunctionVariableInfo, 6, 2>
{};
+ class FunctionVariableMode: public BitField<VariableMode, 8, 3>
{};
// BitFields representing the encoded information for context locals in
the
// ContextLocalInfoEntries part.
@@ -5019,12 +5019,20 @@
// spending time attempting to optimize it again.
DECL_BOOLEAN_ACCESSORS(optimization_disabled)
- // Indicates whether the function is a strict mode function.
- inline bool strict_mode();
-
- // Indicates the mode of the function.
- inline StrictModeFlag strict_mode_flag();
- inline void set_strict_mode_flag(StrictModeFlag strict_mode_flag);
+ // Indicates the language mode of the function's code as defined by the
+ // current harmony drafts for the next ES language standard. Possible
+ // values are:
+ // 1. CLASSIC_MODE - Unrestricted syntax and semantics, same as in ES5.
+ // 2. STRICT_MODE - Restricted syntax and semantics, same as in ES5.
+ // 3. EXTENDED_MODE - Only available under the harmony flag, not part of
ES5.
+ inline LanguageMode language_mode();
+ inline void set_language_mode(LanguageMode language_mode);
+
+ // Indicates whether the language mode of this function is CLASSIC_MODE.
+ inline bool is_classic_mode();
+
+ // Indicates whether the language mode of this function is EXTENDED_MODE.
+ inline bool is_extended_mode();
// False if the function definitely does not allocate an arguments
object.
DECL_BOOLEAN_ACCESSORS(uses_arguments)
@@ -5247,6 +5255,7 @@
kCodeAgeShift,
kOptimizationDisabled = kCodeAgeShift + kCodeAgeSize,
kStrictModeFunction,
+ kExtendedModeFunction,
kUsesArguments,
kHasDuplicateParameters,
kNative,
@@ -5277,18 +5286,26 @@
static const int kStrictModeBitWithinByte =
(kStrictModeFunction + kCompilerHintsSmiTagSize) % kBitsPerByte;
+ static const int kExtendedModeBitWithinByte =
+ (kExtendedModeFunction + kCompilerHintsSmiTagSize) % kBitsPerByte;
+
static const int kNativeBitWithinByte =
(kNative + kCompilerHintsSmiTagSize) % kBitsPerByte;
#if __BYTE_ORDER == __LITTLE_ENDIAN
static const int kStrictModeByteOffset = kCompilerHintsOffset +
(kStrictModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte;
+ static const int kExtendedModeByteOffset = kCompilerHintsOffset +
+ (kExtendedModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte;
static const int kNativeByteOffset = kCompilerHintsOffset +
(kNative + kCompilerHintsSmiTagSize) / kBitsPerByte;
#elif __BYTE_ORDER == __BIG_ENDIAN
static const int kStrictModeByteOffset = kCompilerHintsOffset +
(kCompilerHintsSize - 1) -
((kStrictModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte);
+ static const int kExtendedModeByteOffset = kCompilerHintsOffset +
+ (kCompilerHintsSize - 1) -
+ ((kExtendedModeFunction + kCompilerHintsSmiTagSize) / kBitsPerByte);
static const int kNativeByteOffset = kCompilerHintsOffset +
(kCompilerHintsSize - 1) -
((kNative + kCompilerHintsSmiTagSize) / kBitsPerByte);
@@ -5905,7 +5922,7 @@
Object* Lookup(String* src);
Object* LookupEval(String* src,
Context* context,
- StrictModeFlag strict_mode,
+ LanguageMode language_mode,
int scope_position);
Object* LookupRegExp(String* source, JSRegExp::Flags flags);
MaybeObject* Put(String* src, Object* value);
=======================================
--- /branches/bleeding_edge/src/parser.cc Thu Nov 24 05:24:30 2011
+++ /branches/bleeding_edge/src/parser.cc Thu Nov 24 07:17:04 2011
@@ -656,12 +656,12 @@
scope->set_start_position(0);
scope->set_end_position(source->length());
FunctionState function_state(this, scope, isolate());
- top_scope_->SetStrictModeFlag(info->strict_mode_flag());
+ top_scope_->SetLanguageMode(info->language_mode());
ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16);
bool ok = true;
int beg_loc = scanner().location().beg_pos;
ParseSourceElements(body, Token::EOS, &ok);
- if (ok && top_scope_->is_strict_mode()) {
+ if (ok && !top_scope_->is_classic_mode()) {
CheckOctalLiteral(beg_loc, scanner().location().end_pos, &ok);
}
@@ -748,10 +748,11 @@
scope = Scope::DeserializeScopeChain(info->closure()->context(),
scope);
}
FunctionState function_state(this, scope, isolate());
- ASSERT(scope->strict_mode_flag() == kNonStrictMode ||
- scope->strict_mode_flag() == info->strict_mode_flag());
- ASSERT(info->strict_mode_flag() == shared_info->strict_mode_flag());
- scope->SetStrictModeFlag(shared_info->strict_mode_flag());
+ ASSERT(scope->language_mode() != STRICT_MODE |
| !info->is_classic_mode());
+ ASSERT(scope->language_mode() != EXTENDED_MODE ||
+ info->is_extended_mode());
+ ASSERT(info->language_mode() == shared_info->language_mode());
+ scope->SetLanguageMode(shared_info->language_mode());
FunctionLiteral::Type type = shared_info->is_expression()
? (shared_info->is_anonymous()
? FunctionLiteral::ANONYMOUS_EXPRESSION
@@ -1194,11 +1195,12 @@
Handle<String> directive = Handle<String>::cast(literal->handle());
// Check "use strict" directive (ES5 14.1).
- if (!top_scope_->is_strict_mode() &&
+ if (top_scope_->is_classic_mode() &&
directive->Equals(isolate()->heap()->use_strict()) &&
token_loc.end_pos - token_loc.beg_pos ==
isolate()->heap()->use_strict()->length() + 2) {
- top_scope_->SetStrictModeFlag(kStrictMode);
+ top_scope_->SetLanguageMode(harmony_scoping_
+ ? EXTENDED_MODE : STRICT_MODE);
// "use strict" is the only directive for now.
directive_prologue = false;
}
@@ -1336,7 +1338,7 @@
// FunctionDeclaration
// Common language extension is to allow function declaration in
place
// of any statement. This language extension is disabled in strict
mode.
- if (top_scope_->is_strict_mode() || harmony_scoping_) {
+ if (!top_scope_->is_classic_mode()) {
ReportMessageAt(scanner().peek_location(), "strict_function",
Vector<const char*>::empty());
*ok = false;
@@ -1386,7 +1388,7 @@
// Also for block scoped let/const bindings the variable can be
// statically declared.
if (declaration_scope->is_function_scope() ||
- declaration_scope->is_strict_mode_eval_scope() ||
+ declaration_scope->is_strict_or_extended_eval_scope() ||
declaration_scope->is_block_scope()) {
// Declare the variable in the function scope.
var = declaration_scope->LocalLookup(name);
@@ -1466,7 +1468,7 @@
kind,
kNeedsInitialization);
} else if (declaration_scope->is_eval_scope() &&
- !declaration_scope->is_strict_mode()) {
+ declaration_scope->is_classic_mode()) {
// For variable declarations in a non-strict eval scope the proxy is
bound
// to a lookup variable to force a dynamic declaration using the
// DeclareContextSlot runtime function.
@@ -1590,7 +1592,7 @@
Block* Parser::ParseBlock(ZoneStringList* labels, bool* ok) {
- if (harmony_scoping_) return ParseScopedBlock(labels, ok);
+ if (top_scope_->is_extended_mode()) return ParseScopedBlock(labels, ok);
// Block ::
// '{' Statement* '}'
@@ -1706,28 +1708,31 @@
Consume(Token::VAR);
} else if (peek() == Token::CONST) {
Consume(Token::CONST);
- if (harmony_scoping_) {
- if (var_context != kSourceElement &&
- var_context != kForStatement) {
- // In harmony mode 'const' declarations are only allowed in source
- // element positions.
- ReportMessage("unprotected_const", Vector<const char*>::empty());
+ switch (top_scope_->language_mode()) {
+ case CLASSIC_MODE:
+ mode = CONST;
+ init_op = Token::INIT_CONST;
+ break;
+ case STRICT_MODE:
+ ReportMessage("strict_const", Vector<const char*>::empty());
*ok = false;
return NULL;
- }
- mode = CONST_HARMONY;
- init_op = Token::INIT_CONST_HARMONY;
- } else if (top_scope_->is_strict_mode()) {
- ReportMessage("strict_const", Vector<const char*>::empty());
- *ok = false;
- return NULL;
- } else {
- mode = CONST;
- init_op = Token::INIT_CONST;
+ case EXTENDED_MODE:
+ if (var_context != kSourceElement &&
+ var_context != kForStatement) {
+ // In extended mode 'const' declarations are only allowed in
source
+ // element positions.
+ ReportMessage("unprotected_const", Vector<const char*>::empty());
+ *ok = false;
+ return NULL;
+ }
+ mode = CONST_HARMONY;
+ init_op = Token::INIT_CONST_HARMONY;
}
is_const = true;
needs_init = true;
} else if (peek() == Token::LET) {
+ ASSERT(top_scope_->is_extended_mode());
Consume(Token::LET);
if (var_context != kSourceElement &&
var_context != kForStatement) {
@@ -1771,7 +1776,7 @@
if (fni_ != NULL) fni_->PushVariableName(name);
// Strict mode variables may not be named eval or arguments
- if (declaration_scope->is_strict_mode() && IsEvalOrArguments(name)) {
+ if (!declaration_scope->is_classic_mode() && IsEvalOrArguments(name)) {
ReportMessage("strict_var_name", Vector<const char*>::empty());
*ok = false;
return NULL;
@@ -1900,8 +1905,8 @@
} else {
// Add strict mode.
// We may want to pass singleton to avoid Literal allocations.
- StrictModeFlag flag = initialization_scope->strict_mode_flag();
- arguments->Add(NewNumberLiteral(flag));
+ LanguageMode language_mode = initialization_scope->language_mode();
+ arguments->Add(NewNumberLiteral(language_mode));
// Be careful not to assign a value to the global variable if
// we're in a with. The initialization value should not
@@ -2165,7 +2170,7 @@
Expect(Token::WITH, CHECK_OK);
- if (top_scope_->is_strict_mode()) {
+ if (!top_scope_->is_classic_mode()) {
ReportMessage("strict_mode_with", Vector<const char*>::empty());
*ok = false;
return NULL;
@@ -2311,7 +2316,7 @@
catch_scope->set_start_position(scanner().location().beg_pos);
name = ParseIdentifier(CHECK_OK);
- if (top_scope_->is_strict_mode() && IsEvalOrArguments(name)) {
+ if (!top_scope_->is_classic_mode() && IsEvalOrArguments(name)) {
ReportMessage("strict_catch_variable", Vector<const char*>::empty());
*ok = false;
return NULL;
@@ -2662,7 +2667,7 @@
expression = NewThrowReferenceError(type);
}
- if (top_scope_->is_strict_mode()) {
+ if (!top_scope_->is_classic_mode()) {
// Assignment to eval or arguments is disallowed in strict mode.
CheckStrictModeLValue(expression, "strict_lhs_assignment", CHECK_OK);
}
@@ -2871,7 +2876,7 @@
}
// "delete identifier" is a syntax error in strict mode.
- if (op == Token::DELETE && top_scope_->is_strict_mode()) {
+ if (op == Token::DELETE && !top_scope_->is_classic_mode()) {
VariableProxy* operand = expression->AsVariableProxy();
if (operand != NULL && !operand->is_this()) {
ReportMessage("strict_delete", Vector<const char*>::empty());
@@ -2895,7 +2900,7 @@
expression = NewThrowReferenceError(type);
}
- if (top_scope_->is_strict_mode()) {
+ if (!top_scope_->is_classic_mode()) {
// Prefix expression operand in strict mode may not be eval or
arguments.
CheckStrictModeLValue(expression, "strict_lhs_prefix", CHECK_OK);
}
@@ -2930,7 +2935,7 @@
expression = NewThrowReferenceError(type);
}
- if (top_scope_->is_strict_mode()) {
+ if (!top_scope_->is_classic_mode()) {
// Postfix expression operand in strict mode may not be eval or
arguments.
CheckStrictModeLValue(expression, "strict_lhs_prefix", CHECK_OK);
}
@@ -3161,9 +3166,9 @@
return ReportMessage("unexpected_reserved",
Vector<const char*>::empty());
case Token::FUTURE_STRICT_RESERVED_WORD:
- return ReportMessage(top_scope_->is_strict_mode() ?
- "unexpected_strict_reserved" :
- "unexpected_token_identifier",
+ return ReportMessage(top_scope_->is_classic_mode() ?
+ "unexpected_token_identifier" :
+ "unexpected_strict_reserved",
Vector<const char*>::empty());
default:
const char* name = Token::String(token);
@@ -3509,11 +3514,11 @@
// Validation per 11.1.5 Object Initialiser
class ObjectLiteralPropertyChecker {
public:
- ObjectLiteralPropertyChecker(Parser* parser, bool strict) :
+ ObjectLiteralPropertyChecker(Parser* parser, LanguageMode
language_mode) :
props(&IsEqualString),
elems(&IsEqualNumber),
parser_(parser),
- strict_(strict) {
+ language_mode_(language_mode) {
}
void CheckProperty(
@@ -3543,7 +3548,7 @@
HashMap props;
HashMap elems;
Parser* parser_;
- bool strict_;
+ LanguageMode language_mode_;
};
@@ -3592,8 +3597,8 @@
intptr_t prev = reinterpret_cast<intptr_t> (entry->value);
intptr_t curr = GetPropertyKind(property);
- // Duplicate data properties are illegal in strict mode.
- if (strict_ && (curr & prev & kData) != 0) {
+ // Duplicate data properties are illegal in strict or extended mode.
+ if (language_mode_ != CLASSIC_MODE && (curr & prev & kData) != 0) {
parser_->ReportMessageAt(loc, "strict_duplicate_property",
Vector<const char*>::empty());
*ok = false;
@@ -3729,7 +3734,7 @@
int number_of_boilerplate_properties = 0;
bool has_function = false;
- ObjectLiteralPropertyChecker checker(this, top_scope_->is_strict_mode());
+ ObjectLiteralPropertyChecker checker(this, top_scope_->language_mode());
Expect(Token::LBRACE, CHECK_OK);
@@ -4035,7 +4040,7 @@
scanner().SeekForward(scope->end_position() - 1);
materialized_literal_count = entry.literal_count();
expected_property_count = entry.property_count();
- top_scope_->SetStrictModeFlag(entry.strict_mode_flag());
+ top_scope_->SetLanguageMode(entry.language_mode());
only_simple_this_property_assignments = false;
this_property_assignments =
isolate()->factory()->empty_fixed_array();
Expect(Token::RBRACE, CHECK_OK);
@@ -4068,7 +4073,7 @@
}
// Validate strict mode.
- if (top_scope_->is_strict_mode()) {
+ if (!top_scope_->is_classic_mode()) {
if (IsEvalOrArguments(function_name)) {
int start_pos = scope->start_position();
int position = function_token_position != RelocInfo::kNoPosition
@@ -4254,7 +4259,7 @@
// Parses an identifier that is valid for the current scope, in particular
it
// fails on strict mode future reserved keywords in a strict scope.
Handle<String> Parser::ParseIdentifier(bool* ok) {
- if (top_scope_->is_strict_mode()) {
+ if (!top_scope_->is_classic_mode()) {
Expect(Token::IDENTIFIER, ok);
} else if (!Check(Token::IDENTIFIER)) {
Expect(Token::FUTURE_STRICT_RESERVED_WORD, ok);
@@ -4297,7 +4302,7 @@
void Parser::CheckStrictModeLValue(Expression* expression,
const char* error,
bool* ok) {
- ASSERT(top_scope_->is_strict_mode());
+ ASSERT(!top_scope_->is_classic_mode());
VariableProxy* lhs = expression != NULL
? expression->AsVariableProxy()
: NULL;
=======================================
--- /branches/bleeding_edge/src/parser.h Fri Nov 18 00:59:33 2011
+++ /branches/bleeding_edge/src/parser.h Thu Nov 24 07:17:04 2011
@@ -72,7 +72,7 @@
kEndPositionIndex,
kLiteralCountIndex,
kPropertyCountIndex,
- kStrictModeIndex,
+ kLanguageModeIndex,
kSize
};
@@ -83,10 +83,11 @@
int end_pos() { return backing_[kEndPositionIndex]; }
int literal_count() { return backing_[kLiteralCountIndex]; }
int property_count() { return backing_[kPropertyCountIndex]; }
- StrictModeFlag strict_mode_flag() {
- ASSERT(backing_[kStrictModeIndex] == kStrictMode ||
- backing_[kStrictModeIndex] == kNonStrictMode);
- return static_cast<StrictModeFlag>(backing_[kStrictModeIndex]);
+ LanguageMode language_mode() {
+ ASSERT(backing_[kLanguageModeIndex] == CLASSIC_MODE ||
+ backing_[kLanguageModeIndex] == STRICT_MODE ||
+ backing_[kLanguageModeIndex] == EXTENDED_MODE);
+ return static_cast<LanguageMode>(backing_[kLanguageModeIndex]);
}
bool is_valid() { return !backing_.is_empty(); }
=======================================
--- /branches/bleeding_edge/src/preparse-data.h Thu Oct 27 06:08:51 2011
+++ /branches/bleeding_edge/src/preparse-data.h Thu Nov 24 07:17:04 2011
@@ -49,7 +49,7 @@
int end,
int literals,
int properties,
- StrictModeFlag strict_mode) = 0;
+ LanguageMode language_mode) = 0;
// Logs a symbol creation of a literal or identifier.
virtual void LogAsciiSymbol(int start, Vector<const char> literal) { }
@@ -89,12 +89,12 @@
int end,
int literals,
int properties,
- StrictModeFlag strict_mode) {
+ LanguageMode language_mode) {
function_store_.Add(start);
function_store_.Add(end);
function_store_.Add(literals);
function_store_.Add(properties);
- function_store_.Add(strict_mode);
+ function_store_.Add(language_mode);
}
// Logs an error message and marks the log as containing an error.
=======================================
--- /branches/bleeding_edge/src/preparser.cc Tue Nov 1 00:47:15 2011
+++ /branches/bleeding_edge/src/preparser.cc Thu Nov 24 07:17:04 2011
@@ -149,7 +149,8 @@
Statement statement = ParseSourceElement(CHECK_OK);
if (allow_directive_prologue) {
if (statement.IsUseStrictLiteral()) {
- set_strict_mode();
+ set_language_mode(harmony_scoping_ ?
+ i::EXTENDED_MODE : i::STRICT_MODE);
} else if (!statement.IsStringLiteral()) {
allow_directive_prologue = false;
}
@@ -242,7 +243,7 @@
i::Scanner::Location start_location = scanner_->peek_location();
Statement statement = ParseFunctionDeclaration(CHECK_OK);
i::Scanner::Location end_location = scanner_->location();
- if (strict_mode() || harmony_scoping_) {
+ if (!is_classic_mode()) {
ReportMessageAt(start_location.beg_pos, end_location.end_pos,
"strict_function", NULL);
*ok = false;
@@ -295,7 +296,7 @@
//
Expect(i::Token::LBRACE, CHECK_OK);
while (peek() != i::Token::RBRACE) {
- if (harmony_scoping_) {
+ if (is_extended_mode()) {
ParseSourceElement(CHECK_OK);
} else {
ParseStatement(CHECK_OK);
@@ -348,24 +349,30 @@
if (peek() == i::Token::VAR) {
Consume(i::Token::VAR);
} else if (peek() == i::Token::CONST) {
- if (harmony_scoping_) {
- if (var_context != kSourceElement &&
- var_context != kForStatement) {
+ switch (language_mode()) {
+ case i::CLASSIC_MODE:
+ break;
+ case i::STRICT_MODE: {
i::Scanner::Location location = scanner_->peek_location();
- ReportMessageAt(location.beg_pos, location.end_pos,
- "unprotected_const", NULL);
+ ReportMessageAt(location, "strict_const", NULL);
*ok = false;
return Statement::Default();
}
- require_initializer = true;
- } else if (strict_mode()) {
- i::Scanner::Location location = scanner_->peek_location();
- ReportMessageAt(location, "strict_const", NULL);
- *ok = false;
- return Statement::Default();
+ case i::EXTENDED_MODE:
+ if (var_context != kSourceElement &&
+ var_context != kForStatement) {
+ i::Scanner::Location location = scanner_->peek_location();
+ ReportMessageAt(location.beg_pos, location.end_pos,
+ "unprotected_const", NULL);
+ *ok = false;
+ return Statement::Default();
+ }
+ require_initializer = true;
+ break;
}
Consume(i::Token::CONST);
} else if (peek() == i::Token::LET) {
+ ASSERT(is_extended_mode());
if (var_context != kSourceElement &&
var_context != kForStatement) {
i::Scanner::Location location = scanner_->peek_location();
@@ -389,7 +396,7 @@
// Parse variable name.
if (nvars > 0) Consume(i::Token::COMMA);
Identifier identifier = ParseIdentifier(CHECK_OK);
- if (strict_mode() && !identifier.IsValidStrictVariable()) {
+ if (!is_classic_mode() && !identifier.IsValidStrictVariable()) {
StrictModeIdentifierViolation(scanner_->location(),
"strict_var_name",
identifier,
@@ -417,7 +424,7 @@
Expression expr = ParseExpression(true, CHECK_OK);
if (expr.IsRawIdentifier()) {
ASSERT(!expr.AsIdentifier().IsFutureReserved());
- ASSERT(!strict_mode() |
| !expr.AsIdentifier().IsFutureStrictReserved());
+ ASSERT(is_classic_mode() |
| !expr.AsIdentifier().IsFutureStrictReserved());
if (peek() == i::Token::COLON) {
Consume(i::Token::COLON);
return ParseStatement(ok);
@@ -513,7 +520,7 @@
// WithStatement ::
// 'with' '(' Expression ')' Statement
Expect(i::Token::WITH, CHECK_OK);
- if (strict_mode()) {
+ if (!is_classic_mode()) {
i::Scanner::Location location = scanner_->location();
ReportMessageAt(location, "strict_mode_with", NULL);
*ok = false;
@@ -682,7 +689,7 @@
Consume(i::Token::CATCH);
Expect(i::Token::LPAREN, CHECK_OK);
Identifier id = ParseIdentifier(CHECK_OK);
- if (strict_mode() && !id.IsValidStrictVariable()) {
+ if (!is_classic_mode() && !id.IsValidStrictVariable()) {
StrictModeIdentifierViolation(scanner_->location(),
"strict_catch_variable",
id,
@@ -760,7 +767,8 @@
return expression;
}
- if (strict_mode() && expression.IsIdentifier() &&
+ if (!is_classic_mode() &&
+ expression.IsIdentifier() &&
expression.AsIdentifier().IsEvalOrArguments()) {
i::Scanner::Location after = scanner_->location();
ReportMessageAt(before.beg_pos, after.end_pos,
@@ -848,7 +856,8 @@
op = Next();
i::Scanner::Location before = scanner_->peek_location();
Expression expression = ParseUnaryExpression(CHECK_OK);
- if (strict_mode() && expression.IsIdentifier() &&
+ if (!is_classic_mode() &&
+ expression.IsIdentifier() &&
expression.AsIdentifier().IsEvalOrArguments()) {
i::Scanner::Location after = scanner_->location();
ReportMessageAt(before.beg_pos, after.end_pos,
@@ -870,7 +879,8 @@
Expression expression = ParseLeftHandSideExpression(CHECK_OK);
if (!scanner_->HasAnyLineTerminatorBeforeNext() &&
i::Token::IsCountOp(peek())) {
- if (strict_mode() && expression.IsIdentifier() &&
+ if (!is_classic_mode() &&
+ expression.IsIdentifier() &&
expression.AsIdentifier().IsEvalOrArguments()) {
i::Scanner::Location after = scanner_->location();
ReportMessageAt(before.beg_pos, after.end_pos,
@@ -1057,7 +1067,7 @@
}
case i::Token::FUTURE_STRICT_RESERVED_WORD:
- if (strict_mode()) {
+ if (!is_classic_mode()) {
Next();
i::Scanner::Location location = scanner_->location();
ReportMessageAt(location, "strict_reserved_word", NULL);
@@ -1157,7 +1167,7 @@
if (HasConflict(old_type, type)) {
if (IsDataDataConflict(old_type, type)) {
// Both are data properties.
- if (!strict_mode()) return;
+ if (is_classic_mode()) return;
ReportMessageAt(scanner_->location(),
"strict_duplicate_property", NULL);
} else if (IsDataAccessorConflict(old_type, type)) {
@@ -1364,13 +1374,13 @@
log_->LogFunction(function_block_pos, end_pos,
function_scope.materialized_literal_count(),
function_scope.expected_properties(),
- strict_mode_flag());
+ language_mode());
} else {
ParseSourceElements(i::Token::RBRACE, CHECK_OK);
Expect(i::Token::RBRACE, CHECK_OK);
}
- if (strict_mode()) {
+ if (!is_classic_mode()) {
int end_position = scanner_->location().end_pos;
CheckOctalLiteral(start_position, end_position, CHECK_OK);
CheckDelayedStrictModeViolation(start_position, end_position,
CHECK_OK);
@@ -1474,7 +1484,7 @@
return GetIdentifierSymbol();
}
case i::Token::FUTURE_STRICT_RESERVED_WORD:
- if (strict_mode()) {
+ if (!is_classic_mode()) {
i::Scanner::Location location = scanner_->location();
ReportMessageAt(location.beg_pos, location.end_pos,
"strict_reserved_word", NULL);
@@ -1493,7 +1503,7 @@
void PreParser::SetStrictModeViolation(i::Scanner::Location location,
const char* type,
bool* ok) {
- if (strict_mode()) {
+ if (!is_classic_mode()) {
ReportMessageAt(location, type, NULL);
*ok = false;
return;
@@ -1533,7 +1543,7 @@
} else if (identifier.IsFutureStrictReserved()) {
type = "strict_reserved_word";
}
- if (strict_mode()) {
+ if (!is_classic_mode()) {
ReportMessageAt(location, type, NULL);
*ok = false;
return;
=======================================
--- /branches/bleeding_edge/src/preparser.h Tue Nov 1 00:47:15 2011
+++ /branches/bleeding_edge/src/preparser.h Thu Nov 24 07:17:04 2011
@@ -417,8 +417,8 @@
materialized_literal_count_(0),
expected_properties_(0),
with_nesting_count_(0),
- strict_mode_flag_((prev_ != NULL) ? prev_->strict_mode_flag()
- : i::kNonStrictMode) {
+ language_mode_(
+ (prev_ != NULL) ? prev_->language_mode() : i::CLASSIC_MODE) {
*variable = this;
}
~Scope() { *variable_ = prev_; }
@@ -428,12 +428,14 @@
int expected_properties() { return expected_properties_; }
int materialized_literal_count() { return materialized_literal_count_;
}
bool IsInsideWith() { return with_nesting_count_ != 0; }
- bool is_strict_mode() { return strict_mode_flag_ == i::kStrictMode; }
- i::StrictModeFlag strict_mode_flag() {
- return strict_mode_flag_;
- }
- void set_strict_mode_flag(i::StrictModeFlag strict_mode_flag) {
- strict_mode_flag_ = strict_mode_flag;
+ bool is_classic_mode() {
+ return language_mode_ == i::CLASSIC_MODE;
+ }
+ i::LanguageMode language_mode() {
+ return language_mode_;
+ }
+ void set_language_mode(i::LanguageMode language_mode) {
+ language_mode_ = language_mode;
}
void EnterWith() { with_nesting_count_++; }
void LeaveWith() { with_nesting_count_--; }
@@ -445,7 +447,7 @@
int materialized_literal_count_;
int expected_properties_;
int with_nesting_count_;
- i::StrictModeFlag strict_mode_flag_;
+ i::LanguageMode language_mode_;
};
// Private constructor only used in PreParseProgram.
@@ -476,7 +478,7 @@
if (stack_overflow_) return kPreParseStackOverflow;
if (!ok) {
ReportUnexpectedToken(scanner_->current_token());
- } else if (scope_->is_strict_mode()) {
+ } else if (!scope_->is_classic_mode()) {
CheckOctalLiteral(start_position, scanner_->location().end_pos, &ok);
}
return kPreParseSuccess;
@@ -580,13 +582,19 @@
bool peek_any_identifier();
- void set_strict_mode() {
- scope_->set_strict_mode_flag(i::kStrictMode);
+ void set_language_mode(i::LanguageMode language_mode) {
+ scope_->set_language_mode(language_mode);
}
- bool strict_mode() { return scope_->strict_mode_flag() ==
i::kStrictMode; }
-
- i::StrictModeFlag strict_mode_flag() { return
scope_->strict_mode_flag(); }
+ bool is_classic_mode() {
+ return scope_->language_mode() == i::CLASSIC_MODE;
+ }
+
+ bool is_extended_mode() {
+ return scope_->language_mode() == i::EXTENDED_MODE;
+ }
+
+ i::LanguageMode language_mode() { return scope_->language_mode(); }
void Consume(i::Token::Value token) { Next(); }
=======================================
--- /branches/bleeding_edge/src/runtime.cc Tue Nov 22 02:15:00 2011
+++ /branches/bleeding_edge/src/runtime.cc Thu Nov 24 07:17:04 2011
@@ -116,6 +116,17 @@
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);
@@ -1325,13 +1336,15 @@
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));
}
}
@@ -1437,7 +1450,7 @@
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
@@ -1448,7 +1461,9 @@
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.
@@ -1477,7 +1492,7 @@
// 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();
}
@@ -1489,7 +1504,7 @@
// 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();
}
@@ -1859,7 +1874,7 @@
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
@@ -4682,8 +4697,8 @@
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);
}
@@ -5109,7 +5124,7 @@
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)));
}
@@ -9036,7 +9051,9 @@
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;
@@ -9404,7 +9421,7 @@
// 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,
@@ -9417,7 +9434,7 @@
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());
@@ -9436,7 +9453,7 @@
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 =
@@ -9462,12 +9479,12 @@
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));
}
@@ -9481,9 +9498,9 @@
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());
@@ -10943,7 +10960,9 @@
// 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
@@ -12015,7 +12034,7 @@
Compiler::CompileEval(function_source,
context,
context->IsGlobalContext(),
- kNonStrictMode,
+ CLASSIC_MODE,
RelocInfo::kNoPosition);
if (shared.is_null()) return Failure::Exception();
Handle<JSFunction> compiled_function =
@@ -12109,7 +12128,7 @@
Compiler::CompileEval(source,
context,
is_global,
- kNonStrictMode,
+ CLASSIC_MODE,
RelocInfo::kNoPosition);
if (shared.is_null()) return Failure::Exception();
Handle<JSFunction> compiled_function =
=======================================
--- /branches/bleeding_edge/src/runtime.h Tue Nov 22 02:15:00 2011
+++ /branches/bleeding_edge/src/runtime.h Thu Nov 24 07:17:04 2011
@@ -684,9 +684,9 @@
//---------------------------------------------------------------------------
// Constants used by interface to runtime functions.
-class DeclareGlobalsEvalFlag: public BitField<bool, 0, 1>
{};
-class DeclareGlobalsStrictModeFlag: public BitField<StrictModeFlag, 1, 1>
{};
-class DeclareGlobalsNativeFlag: public BitField<bool, 2, 1>
{};
+class DeclareGlobalsEvalFlag: public BitField<bool, 0, 1> {};
+class DeclareGlobalsNativeFlag: public BitField<bool, 1, 1> {};
+class DeclareGlobalsLanguageMode: public BitField<LanguageMode, 2, 2> {};
} } // namespace v8::internal
=======================================
***Additional files exist in this changeset.***