Commit 4ee51619 authored by cdai2's avatar cdai2

X87: Introduce LanguageMode, drop StrictMode.

port c7851da4 (r26419)

original commit message:

  Introduce LanguageMode, drop StrictMode.

  This enables adding more language modes in the future.

  For maximum flexibility, LanguageMode is a bitmask, so we're not restricted to
  use a sequence of language modes which are progressively stricter, but we can
  express the language mode as combination of features.

  For now, LanguageMode can only be "sloppy" or "strict", and there are
  STATIC_ASSERTS in places which need to change when more modes are added.

  LanguageMode is a bit like the old LanguageMode when "extended" mode was still
  around (see https://codereview.chromium.org/8417035 and
  https://codereview.chromium.org/181543002 ) except that it's transmitted through
  all the layers (there's no StrictModeFlag).

BUG=
R=weiliang.lin@intel.com

Review URL: https://codereview.chromium.org/902053005

Cr-Commit-Position: refs/heads/master@{#26514}
parent 525c1794
...@@ -15,8 +15,8 @@ namespace internal { ...@@ -15,8 +15,8 @@ namespace internal {
#define __ ACCESS_MASM(masm) #define __ ACCESS_MASM(masm)
void PropertyICCompiler::GenerateRuntimeSetProperty(MacroAssembler* masm, void PropertyICCompiler::GenerateRuntimeSetProperty(
StrictMode strict_mode) { MacroAssembler* masm, LanguageMode language_mode) {
// Return address is on the stack. // Return address is on the stack.
DCHECK(!ebx.is(StoreDescriptor::ReceiverRegister()) && DCHECK(!ebx.is(StoreDescriptor::ReceiverRegister()) &&
!ebx.is(StoreDescriptor::NameRegister()) && !ebx.is(StoreDescriptor::NameRegister()) &&
...@@ -25,7 +25,7 @@ void PropertyICCompiler::GenerateRuntimeSetProperty(MacroAssembler* masm, ...@@ -25,7 +25,7 @@ void PropertyICCompiler::GenerateRuntimeSetProperty(MacroAssembler* masm,
__ push(StoreDescriptor::ReceiverRegister()); __ push(StoreDescriptor::ReceiverRegister());
__ push(StoreDescriptor::NameRegister()); __ push(StoreDescriptor::NameRegister());
__ push(StoreDescriptor::ValueRegister()); __ push(StoreDescriptor::ValueRegister());
__ push(Immediate(Smi::FromInt(strict_mode))); __ push(Immediate(Smi::FromInt(language_mode)));
__ push(ebx); // return address __ push(ebx); // return address
// Do tail-call to runtime routine. // Do tail-call to runtime routine.
......
...@@ -612,7 +612,7 @@ static void KeyedStoreGenerateMegamorphicHelper( ...@@ -612,7 +612,7 @@ static void KeyedStoreGenerateMegamorphicHelper(
void KeyedStoreIC::GenerateMegamorphic(MacroAssembler* masm, void KeyedStoreIC::GenerateMegamorphic(MacroAssembler* masm,
StrictMode strict_mode) { LanguageMode language_mode) {
// Return address is on the stack. // Return address is on the stack.
Label slow, fast_object, fast_object_grow; Label slow, fast_object, fast_object_grow;
Label fast_double, fast_double_grow; Label fast_double, fast_double_grow;
...@@ -649,7 +649,7 @@ void KeyedStoreIC::GenerateMegamorphic(MacroAssembler* masm, ...@@ -649,7 +649,7 @@ void KeyedStoreIC::GenerateMegamorphic(MacroAssembler* masm,
// Slow case: call runtime. // Slow case: call runtime.
__ bind(&slow); __ bind(&slow);
PropertyICCompiler::GenerateRuntimeSetProperty(masm, strict_mode); PropertyICCompiler::GenerateRuntimeSetProperty(masm, language_mode);
// Never returns to here. // Never returns to here.
__ bind(&maybe_name_key); __ bind(&maybe_name_key);
......
...@@ -114,7 +114,7 @@ void FullCodeGenerator::Generate() { ...@@ -114,7 +114,7 @@ void FullCodeGenerator::Generate() {
// Sloppy mode functions and builtins need to replace the receiver with the // Sloppy mode functions and builtins need to replace the receiver with the
// global proxy when called as functions (without an explicit receiver // global proxy when called as functions (without an explicit receiver
// object). // object).
if (info->strict_mode() == SLOPPY && !info->is_native()) { if (is_sloppy(info->language_mode()) && !info->is_native()) {
Label ok; Label ok;
// +1 for return address. // +1 for return address.
int receiver_offset = (info->scope()->num_parameters() + 1) * kPointerSize; int receiver_offset = (info->scope()->num_parameters() + 1) * kPointerSize;
...@@ -254,7 +254,7 @@ void FullCodeGenerator::Generate() { ...@@ -254,7 +254,7 @@ void FullCodeGenerator::Generate() {
// The stub will rewrite receiver and parameter count if the previous // The stub will rewrite receiver and parameter count if the previous
// stack frame was an arguments adapter frame. // stack frame was an arguments adapter frame.
ArgumentsAccessStub::Type type; ArgumentsAccessStub::Type type;
if (strict_mode() == STRICT) { if (is_strict(language_mode())) {
type = ArgumentsAccessStub::NEW_STRICT; type = ArgumentsAccessStub::NEW_STRICT;
} else if (function()->has_duplicate_parameters()) { } else if (function()->has_duplicate_parameters()) {
type = ArgumentsAccessStub::NEW_SLOPPY_SLOW; type = ArgumentsAccessStub::NEW_SLOPPY_SLOW;
...@@ -1211,7 +1211,7 @@ void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, ...@@ -1211,7 +1211,7 @@ void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info,
!pretenure && !pretenure &&
scope()->is_function_scope() && scope()->is_function_scope() &&
info->num_literals() == 0) { info->num_literals() == 0) {
FastNewClosureStub stub(isolate(), info->strict_mode(), info->kind()); FastNewClosureStub stub(isolate(), info->language_mode(), info->kind());
__ mov(ebx, Immediate(info)); __ mov(ebx, Immediate(info));
__ CallStub(&stub); __ CallStub(&stub);
} else { } else {
...@@ -1658,7 +1658,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { ...@@ -1658,7 +1658,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
VisitForStackValue(value); VisitForStackValue(value);
if (property->emit_store()) { if (property->emit_store()) {
EmitSetHomeObjectIfNeeded(value, 2); EmitSetHomeObjectIfNeeded(value, 2);
__ push(Immediate(Smi::FromInt(SLOPPY))); // Strict mode __ push(Immediate(Smi::FromInt(SLOPPY))); // Language mode
__ CallRuntime(Runtime::kSetProperty, 4); __ CallRuntime(Runtime::kSetProperty, 4);
} else { } else {
__ Drop(3); __ Drop(3);
...@@ -2567,7 +2567,7 @@ void FullCodeGenerator::EmitAssignment(Expression* expr) { ...@@ -2567,7 +2567,7 @@ void FullCodeGenerator::EmitAssignment(Expression* expr) {
__ pop(StoreDescriptor::ReceiverRegister()); // Receiver. __ pop(StoreDescriptor::ReceiverRegister()); // Receiver.
__ pop(StoreDescriptor::ValueRegister()); // Restore value. __ pop(StoreDescriptor::ValueRegister()); // Restore value.
Handle<Code> ic = Handle<Code> ic =
CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code(); CodeFactory::KeyedStoreIC(isolate(), language_mode()).code();
CallIC(ic); CallIC(ic);
break; break;
} }
...@@ -2633,7 +2633,7 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, ...@@ -2633,7 +2633,7 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var,
__ push(eax); // Value. __ push(eax); // Value.
__ push(esi); // Context. __ push(esi); // Context.
__ push(Immediate(var->name())); __ push(Immediate(var->name()));
__ push(Immediate(Smi::FromInt(strict_mode()))); __ push(Immediate(Smi::FromInt(language_mode())));
__ CallRuntime(Runtime::kStoreLookupSlot, 4); __ CallRuntime(Runtime::kStoreLookupSlot, 4);
} else { } else {
// Assignment to var or initializing assignment to let/const in harmony // Assignment to var or initializing assignment to let/const in harmony
...@@ -2648,7 +2648,7 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, ...@@ -2648,7 +2648,7 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var,
} }
EmitStoreToStackLocalOrContextSlot(var, location); EmitStoreToStackLocalOrContextSlot(var, location);
} }
} else if (IsSignallingAssignmentToConst(var, op, strict_mode())) { } else if (IsSignallingAssignmentToConst(var, op, language_mode())) {
__ CallRuntime(Runtime::kThrowConstAssignError, 0); __ CallRuntime(Runtime::kThrowConstAssignError, 0);
} }
} }
...@@ -2683,8 +2683,8 @@ void FullCodeGenerator::EmitNamedSuperPropertyStore(Property* prop) { ...@@ -2683,8 +2683,8 @@ void FullCodeGenerator::EmitNamedSuperPropertyStore(Property* prop) {
__ push(Immediate(key->value())); __ push(Immediate(key->value()));
__ push(eax); __ push(eax);
__ CallRuntime((strict_mode() == STRICT ? Runtime::kStoreToSuper_Strict __ CallRuntime((is_strict(language_mode()) ? Runtime::kStoreToSuper_Strict
: Runtime::kStoreToSuper_Sloppy), : Runtime::kStoreToSuper_Sloppy),
4); 4);
} }
...@@ -2695,9 +2695,10 @@ void FullCodeGenerator::EmitKeyedSuperPropertyStore(Property* prop) { ...@@ -2695,9 +2695,10 @@ void FullCodeGenerator::EmitKeyedSuperPropertyStore(Property* prop) {
// stack : receiver ('this'), home_object, key // stack : receiver ('this'), home_object, key
__ push(eax); __ push(eax);
__ CallRuntime((strict_mode() == STRICT ? Runtime::kStoreKeyedToSuper_Strict __ CallRuntime(
: Runtime::kStoreKeyedToSuper_Sloppy), (is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict
4); : Runtime::kStoreKeyedToSuper_Sloppy),
4);
} }
...@@ -2712,7 +2713,8 @@ void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { ...@@ -2712,7 +2713,8 @@ void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) {
DCHECK(StoreDescriptor::ValueRegister().is(eax)); DCHECK(StoreDescriptor::ValueRegister().is(eax));
// Record source code position before IC call. // Record source code position before IC call.
SetSourcePosition(expr->position()); SetSourcePosition(expr->position());
Handle<Code> ic = CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code(); Handle<Code> ic =
CodeFactory::KeyedStoreIC(isolate(), language_mode()).code();
CallIC(ic, expr->AssignmentFeedbackId()); CallIC(ic, expr->AssignmentFeedbackId());
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
...@@ -2927,7 +2929,7 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { ...@@ -2927,7 +2929,7 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) {
// Push the receiver of the enclosing function. // Push the receiver of the enclosing function.
__ push(Operand(ebp, (2 + info_->scope()->num_parameters()) * kPointerSize)); __ push(Operand(ebp, (2 + info_->scope()->num_parameters()) * kPointerSize));
// Push the language mode. // Push the language mode.
__ push(Immediate(Smi::FromInt(strict_mode()))); __ push(Immediate(Smi::FromInt(language_mode())));
// Push the start position of the scope the calls resides in. // Push the start position of the scope the calls resides in.
__ push(Immediate(Smi::FromInt(scope()->start_position()))); __ push(Immediate(Smi::FromInt(scope()->start_position())));
...@@ -4498,14 +4500,14 @@ void FullCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { ...@@ -4498,14 +4500,14 @@ void FullCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) {
if (property != NULL) { if (property != NULL) {
VisitForStackValue(property->obj()); VisitForStackValue(property->obj());
VisitForStackValue(property->key()); VisitForStackValue(property->key());
__ push(Immediate(Smi::FromInt(strict_mode()))); __ push(Immediate(Smi::FromInt(language_mode())));
__ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION); __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
context()->Plug(eax); context()->Plug(eax);
} else if (proxy != NULL) { } else if (proxy != NULL) {
Variable* var = proxy->var(); Variable* var = proxy->var();
// Delete of an unqualified identifier is disallowed in strict mode // Delete of an unqualified identifier is disallowed in strict mode
// but "delete this" is allowed. // but "delete this" is allowed.
DCHECK(strict_mode() == SLOPPY || var->is_this()); DCHECK(is_sloppy(language_mode()) || var->is_this());
if (var->IsUnallocated()) { if (var->IsUnallocated()) {
__ push(GlobalObjectOperand()); __ push(GlobalObjectOperand());
__ push(Immediate(var->name())); __ push(Immediate(var->name()));
...@@ -4832,7 +4834,7 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { ...@@ -4832,7 +4834,7 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
__ pop(StoreDescriptor::NameRegister()); __ pop(StoreDescriptor::NameRegister());
__ pop(StoreDescriptor::ReceiverRegister()); __ pop(StoreDescriptor::ReceiverRegister());
Handle<Code> ic = Handle<Code> ic =
CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code(); CodeFactory::KeyedStoreIC(isolate(), language_mode()).code();
CallIC(ic, expr->CountStoreFeedbackId()); CallIC(ic, expr->CountStoreFeedbackId());
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
if (expr->is_postfix()) { if (expr->is_postfix()) {
......
...@@ -109,8 +109,7 @@ bool LCodeGen::GeneratePrologue() { ...@@ -109,8 +109,7 @@ bool LCodeGen::GeneratePrologue() {
// Sloppy mode functions and builtins need to replace the receiver with the // Sloppy mode functions and builtins need to replace the receiver with the
// global proxy when called as functions (without an explicit receiver // global proxy when called as functions (without an explicit receiver
// object). // object).
if (info_->this_has_uses() && if (info_->this_has_uses() && is_sloppy(info_->language_mode()) &&
info_->strict_mode() == SLOPPY &&
!info_->is_native()) { !info_->is_native()) {
Label ok; Label ok;
// +1 for return address. // +1 for return address.
...@@ -4571,7 +4570,7 @@ void LCodeGen::DoStoreNamedGeneric(LStoreNamedGeneric* instr) { ...@@ -4571,7 +4570,7 @@ void LCodeGen::DoStoreNamedGeneric(LStoreNamedGeneric* instr) {
DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister()));
__ mov(StoreDescriptor::NameRegister(), instr->name()); __ mov(StoreDescriptor::NameRegister(), instr->name());
Handle<Code> ic = StoreIC::initialize_stub(isolate(), instr->strict_mode()); Handle<Code> ic = StoreIC::initialize_stub(isolate(), instr->language_mode());
CallCode(ic, RelocInfo::CODE_TARGET, instr); CallCode(ic, RelocInfo::CODE_TARGET, instr);
} }
...@@ -4802,7 +4801,7 @@ void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { ...@@ -4802,7 +4801,7 @@ void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) {
DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister()));
Handle<Code> ic = Handle<Code> ic =
CodeFactory::KeyedStoreIC(isolate(), instr->strict_mode()).code(); CodeFactory::KeyedStoreIC(isolate(), instr->language_mode()).code();
CallCode(ic, RelocInfo::CODE_TARGET, instr); CallCode(ic, RelocInfo::CODE_TARGET, instr);
} }
...@@ -5974,7 +5973,7 @@ void LCodeGen::DoFunctionLiteral(LFunctionLiteral* instr) { ...@@ -5974,7 +5973,7 @@ void LCodeGen::DoFunctionLiteral(LFunctionLiteral* instr) {
// space for nested functions that don't need literals cloning. // space for nested functions that don't need literals cloning.
bool pretenure = instr->hydrogen()->pretenure(); bool pretenure = instr->hydrogen()->pretenure();
if (!pretenure && instr->hydrogen()->has_no_literals()) { if (!pretenure && instr->hydrogen()->has_no_literals()) {
FastNewClosureStub stub(isolate(), instr->hydrogen()->strict_mode(), FastNewClosureStub stub(isolate(), instr->hydrogen()->language_mode(),
instr->hydrogen()->kind()); instr->hydrogen()->kind());
__ mov(ebx, Immediate(instr->hydrogen()->shared_info())); __ mov(ebx, Immediate(instr->hydrogen()->shared_info()));
CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
......
...@@ -160,7 +160,7 @@ class LCodeGen: public LCodeGenBase { ...@@ -160,7 +160,7 @@ class LCodeGen: public LCodeGenBase {
#undef DECLARE_DO #undef DECLARE_DO
private: private:
StrictMode strict_mode() const { return info()->strict_mode(); } LanguageMode language_mode() const { return info()->language_mode(); }
Scope* scope() const { return scope_; } Scope* scope() const { return scope_; }
......
...@@ -2238,7 +2238,7 @@ class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> { ...@@ -2238,7 +2238,7 @@ class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> {
void PrintDataTo(StringStream* stream) OVERRIDE; void PrintDataTo(StringStream* stream) OVERRIDE;
Handle<Object> name() const { return hydrogen()->name(); } Handle<Object> name() const { return hydrogen()->name(); }
StrictMode strict_mode() { return hydrogen()->strict_mode(); } LanguageMode language_mode() { return hydrogen()->language_mode(); }
}; };
...@@ -2295,7 +2295,7 @@ class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> { ...@@ -2295,7 +2295,7 @@ class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> {
void PrintDataTo(StringStream* stream) OVERRIDE; void PrintDataTo(StringStream* stream) OVERRIDE;
StrictMode strict_mode() { return hydrogen()->strict_mode(); } LanguageMode language_mode() { return hydrogen()->language_mode(); }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment