// Censor if the caller is not a sloppy mode function.
// Change from ES5, which used to throw, see:
// https://bugs.ecmascript.org/show_bug.cgi?id=310
- if (caller->shared()->strict_mode() == STRICT) {
+ if (is_strict(caller->shared()->language_mode())) {
return MaybeHandle<JSFunction>();
}
// Don't return caller from another security context.
i::MaybeHandle<i::Object> DeleteObjectProperty(
i::Isolate* isolate, i::Handle<i::JSReceiver> receiver,
- i::Handle<i::Object> key, i::StrictMode strict_mode) {
+ i::Handle<i::Object> key, i::LanguageMode language_mode) {
// Check if the given key is an array index.
uint32_t index;
if (key->ToArrayIndex(&index)) {
return isolate->factory()->true_value();
}
- return i::JSReceiver::DeleteElement(receiver, index, strict_mode);
+ return i::JSReceiver::DeleteElement(receiver, index, language_mode);
}
i::Handle<i::Name> name;
if (name->IsString()) {
name = i::String::Flatten(i::Handle<i::String>::cast(name));
}
- return i::JSReceiver::DeleteProperty(receiver, name, strict_mode);
+ return i::JSReceiver::DeleteProperty(receiver, name, language_mode);
}
// Sloppy mode functions and builtins need to replace the receiver with the
// global proxy when called as functions (without an explicit receiver
// object).
- if (info->strict_mode() == SLOPPY && !info->is_native()) {
+ if (is_sloppy(info->language_mode()) && !info->is_native()) {
Label ok;
int receiver_offset = info->scope()->num_parameters() * kPointerSize;
__ ldr(r2, MemOperand(sp, receiver_offset));
// The stub will rewrite receiever and parameter count if the previous
// stack frame was an arguments adapter frame.
ArgumentsAccessStub::Type type;
- if (strict_mode() == STRICT) {
+ if (is_strict(language_mode())) {
type = ArgumentsAccessStub::NEW_STRICT;
} else if (function()->has_duplicate_parameters()) {
type = ArgumentsAccessStub::NEW_SLOPPY_SLOW;
!pretenure &&
scope()->is_function_scope() &&
info->num_literals() == 0) {
- FastNewClosureStub stub(isolate(), info->strict_mode(), info->kind());
+ FastNewClosureStub stub(isolate(), info->language_mode(), info->kind());
__ mov(r2, Operand(info));
__ CallStub(&stub);
} else {
__ Pop(StoreDescriptor::ValueRegister(),
StoreDescriptor::ReceiverRegister());
Handle<Code> ic =
- CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code();
+ CodeFactory::KeyedStoreIC(isolate(), language_mode()).code();
CallIC(ic);
break;
}
// Assignment to var.
__ push(r0); // Value.
__ mov(r1, Operand(var->name()));
- __ mov(r0, Operand(Smi::FromInt(strict_mode())));
- __ Push(cp, r1, r0); // Context, name, strict mode.
+ __ mov(r0, Operand(Smi::FromInt(language_mode())));
+ __ Push(cp, r1, r0); // Context, name, language mode.
__ CallRuntime(Runtime::kStoreLookupSlot, 4);
} else {
// Assignment to var or initializing assignment to let/const in harmony
}
EmitStoreToStackLocalOrContextSlot(var, location);
}
- } else if (IsSignallingAssignmentToConst(var, op, strict_mode())) {
+ } else if (IsSignallingAssignmentToConst(var, op, language_mode())) {
__ CallRuntime(Runtime::kThrowConstAssignError, 0);
}
}
__ Push(key->value());
__ Push(r0);
- __ CallRuntime((strict_mode() == STRICT ? Runtime::kStoreToSuper_Strict
- : Runtime::kStoreToSuper_Sloppy),
+ __ CallRuntime((is_strict(language_mode()) ? Runtime::kStoreToSuper_Strict
+ : Runtime::kStoreToSuper_Sloppy),
4);
}
DCHECK(prop != NULL);
__ Push(r0);
- __ CallRuntime((strict_mode() == STRICT ? Runtime::kStoreKeyedToSuper_Strict
- : Runtime::kStoreKeyedToSuper_Sloppy),
- 4);
+ __ CallRuntime(
+ (is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict
+ : Runtime::kStoreKeyedToSuper_Sloppy),
+ 4);
}
__ Pop(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister());
DCHECK(StoreDescriptor::ValueRegister().is(r0));
- Handle<Code> ic = CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code();
+ Handle<Code> ic =
+ CodeFactory::KeyedStoreIC(isolate(), language_mode()).code();
CallIC(ic, expr->AssignmentFeedbackId());
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
int receiver_offset = 2 + info_->scope()->num_parameters();
__ ldr(r3, MemOperand(fp, receiver_offset * kPointerSize));
- // r2: strict mode.
- __ mov(r2, Operand(Smi::FromInt(strict_mode())));
+ // r2: language mode.
+ __ mov(r2, Operand(Smi::FromInt(language_mode())));
// r1: the start position of the scope the calls resides in.
__ mov(r1, Operand(Smi::FromInt(scope()->start_position())));
if (property != NULL) {
VisitForStackValue(property->obj());
VisitForStackValue(property->key());
- __ mov(r1, Operand(Smi::FromInt(strict_mode())));
+ __ mov(r1, Operand(Smi::FromInt(language_mode())));
__ push(r1);
__ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
context()->Plug(r0);
Variable* var = proxy->var();
// Delete of an unqualified identifier is disallowed in strict mode
// but "delete this" is allowed.
- DCHECK(strict_mode() == SLOPPY || var->is_this());
+ DCHECK(is_sloppy(language_mode()) || var->is_this());
if (var->IsUnallocated()) {
__ ldr(r2, GlobalObjectOperand());
__ mov(r1, Operand(var->name()));
__ Pop(StoreDescriptor::ReceiverRegister(),
StoreDescriptor::NameRegister());
Handle<Code> ic =
- CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code();
+ CodeFactory::KeyedStoreIC(isolate(), language_mode()).code();
CallIC(ic, expr->CountStoreFeedbackId());
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
if (expr->is_postfix()) {
void PrintDataTo(StringStream* stream) OVERRIDE;
Handle<Object> name() const { return hydrogen()->name(); }
- StrictMode strict_mode() { return hydrogen()->strict_mode(); }
+ LanguageMode language_mode() { return hydrogen()->language_mode(); }
};
void PrintDataTo(StringStream* stream) OVERRIDE;
- StrictMode strict_mode() { return hydrogen()->strict_mode(); }
+ LanguageMode language_mode() { return hydrogen()->language_mode(); }
};
// Sloppy mode functions and builtins need to replace the receiver with the
// global proxy when called as functions (without an explicit receiver
// object).
- if (info_->this_has_uses() &&
- info_->strict_mode() == SLOPPY &&
+ if (info_->this_has_uses() && is_sloppy(info_->language_mode()) &&
!info_->is_native()) {
Label ok;
int receiver_offset = info_->scope()->num_parameters() * kPointerSize;
DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister()));
__ mov(StoreDescriptor::NameRegister(), Operand(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, NEVER_INLINE_TARGET_ADDRESS);
}
DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister()));
Handle<Code> ic =
- CodeFactory::KeyedStoreIC(isolate(), instr->strict_mode()).code();
+ CodeFactory::KeyedStoreIC(isolate(), instr->language_mode()).code();
CallCode(ic, RelocInfo::CODE_TARGET, instr, NEVER_INLINE_TARGET_ADDRESS);
}
// space for nested functions that don't need literals cloning.
bool pretenure = instr->hydrogen()->pretenure();
if (!pretenure && instr->hydrogen()->has_no_literals()) {
- FastNewClosureStub stub(isolate(), instr->hydrogen()->strict_mode(),
+ FastNewClosureStub stub(isolate(), instr->hydrogen()->language_mode(),
instr->hydrogen()->kind());
__ mov(r2, Operand(instr->hydrogen()->shared_info()));
CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
#undef DECLARE_DO
private:
- StrictMode strict_mode() const { return info()->strict_mode(); }
+ LanguageMode language_mode() const { return info()->language_mode(); }
Scope* scope() const { return scope_; }
// Sloppy mode functions and builtins need to replace the receiver with the
// global proxy when called as functions (without an explicit receiver
// object).
- if (info->strict_mode() == SLOPPY && !info->is_native()) {
+ if (is_sloppy(info->language_mode()) && !info->is_native()) {
Label ok;
int receiver_offset = info->scope()->num_parameters() * kXRegSize;
__ Peek(x10, receiver_offset);
// The stub will rewrite receiver and parameter count if the previous
// stack frame was an arguments adapter frame.
ArgumentsAccessStub::Type type;
- if (strict_mode() == STRICT) {
+ if (is_strict(language_mode())) {
type = ArgumentsAccessStub::NEW_STRICT;
} else if (function()->has_duplicate_parameters()) {
type = ArgumentsAccessStub::NEW_SLOPPY_SLOW;
!pretenure &&
scope()->is_function_scope() &&
info->num_literals() == 0) {
- FastNewClosureStub stub(isolate(), info->strict_mode(), info->kind());
+ FastNewClosureStub stub(isolate(), info->language_mode(), info->kind());
__ Mov(x2, Operand(info));
__ CallStub(&stub);
} else {
VisitForStackValue(key);
VisitForStackValue(value);
EmitSetHomeObjectIfNeeded(value, 2);
- __ Mov(x0, Smi::FromInt(SLOPPY)); // Strict mode
+ __ Mov(x0, Smi::FromInt(SLOPPY)); // Language mode
__ Push(x0);
__ CallRuntime(Runtime::kSetProperty, 4);
} else {
__ Pop(StoreDescriptor::ReceiverRegister(),
StoreDescriptor::ValueRegister());
Handle<Code> ic =
- CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code();
+ CodeFactory::KeyedStoreIC(isolate(), language_mode()).code();
CallIC(ic);
break;
}
if (var->IsLookupSlot()) {
// Assignment to var.
__ Mov(x11, Operand(var->name()));
- __ Mov(x10, Smi::FromInt(strict_mode()));
+ __ Mov(x10, Smi::FromInt(language_mode()));
// jssp[0] : mode.
// jssp[8] : name.
// jssp[16] : context.
}
EmitStoreToStackLocalOrContextSlot(var, location);
}
- } else if (IsSignallingAssignmentToConst(var, op, strict_mode())) {
+ } else if (IsSignallingAssignmentToConst(var, op, language_mode())) {
__ CallRuntime(Runtime::kThrowConstAssignError, 0);
}
}
__ Push(key->value());
__ Push(x0);
- __ CallRuntime((strict_mode() == STRICT ? Runtime::kStoreToSuper_Strict
- : Runtime::kStoreToSuper_Sloppy),
+ __ CallRuntime((is_strict(language_mode()) ? Runtime::kStoreToSuper_Strict
+ : Runtime::kStoreToSuper_Sloppy),
4);
}
DCHECK(prop != NULL);
__ Push(x0);
- __ CallRuntime((strict_mode() == STRICT ? Runtime::kStoreKeyedToSuper_Strict
- : Runtime::kStoreKeyedToSuper_Sloppy),
- 4);
+ __ CallRuntime(
+ (is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict
+ : Runtime::kStoreKeyedToSuper_Sloppy),
+ 4);
}
__ Pop(StoreDescriptor::NameRegister(), StoreDescriptor::ReceiverRegister());
DCHECK(StoreDescriptor::ValueRegister().is(x0));
- Handle<Code> ic = CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code();
+ Handle<Code> ic =
+ CodeFactory::KeyedStoreIC(isolate(), language_mode()).code();
CallIC(ic, expr->AssignmentFeedbackId());
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
__ Ldr(x11, MemOperand(fp, receiver_offset * kPointerSize));
// Prepare to push the language mode.
- __ Mov(x12, Smi::FromInt(strict_mode()));
+ __ Mov(x12, Smi::FromInt(language_mode()));
// Prepare to push the start position of the scope the calls resides in.
__ Mov(x13, Smi::FromInt(scope()->start_position()));
if (property != NULL) {
VisitForStackValue(property->obj());
VisitForStackValue(property->key());
- __ Mov(x10, Smi::FromInt(strict_mode()));
+ __ Mov(x10, Smi::FromInt(language_mode()));
__ Push(x10);
__ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
context()->Plug(x0);
Variable* var = proxy->var();
// Delete of an unqualified identifier is disallowed in strict mode
// but "delete this" is allowed.
- DCHECK(strict_mode() == SLOPPY || var->is_this());
+ DCHECK(is_sloppy(language_mode()) || var->is_this());
if (var->IsUnallocated()) {
__ Ldr(x12, GlobalObjectMemOperand());
__ Mov(x11, Operand(var->name()));
__ Pop(StoreDescriptor::NameRegister());
__ Pop(StoreDescriptor::ReceiverRegister());
Handle<Code> ic =
- CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code();
+ CodeFactory::KeyedStoreIC(isolate(), language_mode()).code();
CallIC(ic, expr->CountStoreFeedbackId());
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
if (expr->is_postfix()) {
void PrintDataTo(StringStream* stream) OVERRIDE;
- StrictMode strict_mode() { return hydrogen()->strict_mode(); }
+ LanguageMode language_mode() { return hydrogen()->language_mode(); }
};
void PrintDataTo(StringStream* stream) OVERRIDE;
Handle<Object> name() const { return hydrogen()->name(); }
- StrictMode strict_mode() { return hydrogen()->strict_mode(); }
+ LanguageMode language_mode() { return hydrogen()->language_mode(); }
};
// Sloppy mode functions and builtins need to replace the receiver with the
// global proxy when called as functions (without an explicit receiver
// object).
- if (info_->this_has_uses() &&
- info_->strict_mode() == SLOPPY &&
+ if (info_->this_has_uses() && is_sloppy(info_->language_mode()) &&
!info_->is_native()) {
Label ok;
int receiver_offset = info_->scope()->num_parameters() * kXRegSize;
// space for nested functions that don't need literals cloning.
bool pretenure = instr->hydrogen()->pretenure();
if (!pretenure && instr->hydrogen()->has_no_literals()) {
- FastNewClosureStub stub(isolate(), instr->hydrogen()->strict_mode(),
+ FastNewClosureStub stub(isolate(), instr->hydrogen()->language_mode(),
instr->hydrogen()->kind());
__ Mov(x2, Operand(instr->hydrogen()->shared_info()));
CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister()));
Handle<Code> ic =
- CodeFactory::KeyedStoreIC(isolate(), instr->strict_mode()).code();
+ CodeFactory::KeyedStoreIC(isolate(), instr->language_mode()).code();
CallCode(ic, RelocInfo::CODE_TARGET, instr);
}
DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister()));
__ Mov(StoreDescriptor::NameRegister(), Operand(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);
}
}
-StrictMode FunctionLiteral::strict_mode() const {
- return scope()->strict_mode();
+LanguageMode FunctionLiteral::language_mode() const {
+ return scope()->language_mode();
}
int SourceSize() const { return end_position() - start_position(); }
bool is_expression() const { return IsExpression::decode(bitfield_); }
bool is_anonymous() const { return IsAnonymous::decode(bitfield_); }
- StrictMode strict_mode() const;
+ LanguageMode language_mode() const;
bool uses_super_property() const;
bool uses_super_constructor_call() const;
// static
-Callable CodeFactory::StoreIC(Isolate* isolate, StrictMode mode) {
- return Callable(StoreIC::initialize_stub(isolate, mode),
+Callable CodeFactory::StoreIC(Isolate* isolate, LanguageMode language_mode) {
+ return Callable(StoreIC::initialize_stub(isolate, language_mode),
StoreDescriptor(isolate));
}
// static
-Callable CodeFactory::KeyedStoreIC(Isolate* isolate, StrictMode mode) {
- Handle<Code> ic = mode == SLOPPY
- ? isolate->builtins()->KeyedStoreIC_Initialize()
- : isolate->builtins()->KeyedStoreIC_Initialize_Strict();
+Callable CodeFactory::KeyedStoreIC(Isolate* isolate,
+ LanguageMode language_mode) {
+ Handle<Code> ic = is_strict(language_mode)
+ ? isolate->builtins()->KeyedStoreIC_Initialize_Strict()
+ : isolate->builtins()->KeyedStoreIC_Initialize();
return Callable(ic, StoreDescriptor(isolate));
}
CallICState::CallType call_type);
static Callable CallICInOptimizedCode(Isolate* isolate, int argc,
CallICState::CallType call_type);
- static Callable StoreIC(Isolate* isolate, StrictMode mode);
- static Callable KeyedStoreIC(Isolate* isolate, StrictMode mode);
+ static Callable StoreIC(Isolate* isolate, LanguageMode mode);
+ static Callable KeyedStoreIC(Isolate* isolate, LanguageMode mode);
static Callable CompareIC(Isolate* isolate, Token::Value op);
HInstruction* js_function =
Add<HAllocate>(size, HType::JSObject(), NOT_TENURED, JS_FUNCTION_TYPE);
- int map_index = Context::FunctionMapIndex(casted_stub()->strict_mode(),
+ int map_index = Context::FunctionMapIndex(casted_stub()->language_mode(),
casted_stub()->kind());
// Compute the function map in the current native context and set that
class FastNewClosureStub : public HydrogenCodeStub {
public:
- FastNewClosureStub(Isolate* isolate, StrictMode strict_mode,
+ FastNewClosureStub(Isolate* isolate, LanguageMode language_mode,
FunctionKind kind)
: HydrogenCodeStub(isolate) {
DCHECK(IsValidFunctionKind(kind));
- set_sub_minor_key(StrictModeBits::encode(strict_mode) |
+ set_sub_minor_key(LanguageModeBits::encode(language_mode) |
FunctionKindBits::encode(kind));
}
- StrictMode strict_mode() const {
- return StrictModeBits::decode(sub_minor_key());
+ LanguageMode language_mode() const {
+ return LanguageModeBits::decode(sub_minor_key());
}
FunctionKind kind() const {
bool is_default_constructor() const { return IsDefaultConstructor(kind()); }
private:
- class StrictModeBits : public BitField<StrictMode, 0, 1> {};
+ STATIC_ASSERT(LANGUAGE_END == 2);
+ class LanguageModeBits : public BitField<LanguageMode, 0, 1> {};
class FunctionKindBits : public BitField<FunctionKind, 1, 4> {};
DEFINE_CALL_INTERFACE_DESCRIPTOR(FastNewClosure);
MaybeHandle<SharedFunctionInfo> CompilationCacheEval::Lookup(
Handle<String> source, Handle<SharedFunctionInfo> outer_info,
- StrictMode strict_mode, int scope_position) {
+ LanguageMode language_mode, int scope_position) {
HandleScope scope(isolate());
// Make sure not to leak the table into the surrounding handle
// scope. Otherwise, we risk keeping old tables around even after
int generation;
for (generation = 0; generation < generations(); generation++) {
Handle<CompilationCacheTable> table = GetTable(generation);
- result = table->LookupEval(source, outer_info, strict_mode, scope_position);
+ result =
+ table->LookupEval(source, outer_info, language_mode, scope_position);
if (result->IsSharedFunctionInfo()) break;
}
if (result->IsSharedFunctionInfo()) {
MaybeHandle<SharedFunctionInfo> CompilationCache::LookupEval(
Handle<String> source, Handle<SharedFunctionInfo> outer_info,
- Handle<Context> context, StrictMode strict_mode, int scope_position) {
+ Handle<Context> context, LanguageMode language_mode, int scope_position) {
if (!IsEnabled()) return MaybeHandle<SharedFunctionInfo>();
MaybeHandle<SharedFunctionInfo> result;
if (context->IsNativeContext()) {
result =
- eval_global_.Lookup(source, outer_info, strict_mode, scope_position);
+ eval_global_.Lookup(source, outer_info, language_mode, scope_position);
} else {
DCHECK(scope_position != RelocInfo::kNoPosition);
- result = eval_contextual_.Lookup(source, outer_info, strict_mode,
+ result = eval_contextual_.Lookup(source, outer_info, language_mode,
scope_position);
}
return result;
MaybeHandle<SharedFunctionInfo> Lookup(Handle<String> source,
Handle<SharedFunctionInfo> outer_info,
- StrictMode strict_mode,
+ LanguageMode language_mode,
int scope_position);
void Put(Handle<String> source, Handle<SharedFunctionInfo> outer_info,
// contain a script for the given source string.
MaybeHandle<SharedFunctionInfo> LookupEval(
Handle<String> source, Handle<SharedFunctionInfo> outer_info,
- Handle<Context> context, StrictMode strict_mode, int scope_position);
+ Handle<Context> context, LanguageMode language_mode, int scope_position);
// Returns the regexp data associated with the given regexp if it
// is in cache, otherwise an empty handle.
if (FLAG_turbo_types) MarkAsTypingEnabled();
if (!shared_info_.is_null()) {
- DCHECK(strict_mode() == SLOPPY);
- SetStrictMode(shared_info_->strict_mode());
+ DCHECK(is_sloppy(language_mode()));
+ SetLanguageMode(shared_info_->language_mode());
}
bailout_reason_ = kNoReason;
function_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation());
function_info->set_allows_lazy_compilation_without_context(
lit->AllowsLazyCompilationWithoutContext());
- function_info->set_strict_mode(lit->strict_mode());
+ 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());
function_info->set_ast_node_count(lit->ast_node_count());
if (!Parser::Parse(info)) return MaybeHandle<Code>();
Handle<SharedFunctionInfo> shared = info->shared_info();
FunctionLiteral* lit = info->function();
- shared->set_strict_mode(lit->strict_mode());
+ shared->set_language_mode(lit->language_mode());
SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count());
MaybeDisableOptimization(shared, lit->dont_optimize_reason());
MaybeHandle<JSFunction> Compiler::GetFunctionFromEval(
Handle<String> source, Handle<SharedFunctionInfo> outer_info,
- Handle<Context> context, StrictMode strict_mode,
+ Handle<Context> context, LanguageMode language_mode,
ParseRestriction restriction, int scope_position) {
Isolate* isolate = source->GetIsolate();
int source_length = source->length();
CompilationCache* compilation_cache = isolate->compilation_cache();
MaybeHandle<SharedFunctionInfo> maybe_shared_info =
- compilation_cache->LookupEval(source, outer_info, context, strict_mode,
+ compilation_cache->LookupEval(source, outer_info, context, language_mode,
scope_position);
Handle<SharedFunctionInfo> shared_info;
CompilationInfoWithZone info(script);
info.MarkAsEval();
if (context->IsNativeContext()) info.MarkAsGlobal();
- info.SetStrictMode(strict_mode);
+ info.SetLanguageMode(language_mode);
info.SetParseRestriction(restriction);
info.SetContext(context);
}
// If caller is strict mode, the result must be in strict mode as well.
- DCHECK(strict_mode == SLOPPY || shared_info->strict_mode() == STRICT);
+ DCHECK(is_sloppy(language_mode) ||
+ is_strict(shared_info->language_mode()));
if (!shared_info->dont_cache()) {
compilation_cache->PutEval(source, outer_info, context, shared_info,
scope_position);
compile_options == ScriptCompiler::kProduceCodeCache) {
info.PrepareForSerializing();
}
- if (FLAG_use_strict) info.SetStrictMode(STRICT);
+ if (FLAG_use_strict) {
+ info.SetLanguageMode(
+ static_cast<LanguageMode>(info.language_mode() | STRICT));
+ }
result = CompileToplevel(&info);
if (extension == NULL && !result.is_null() && !result->dont_cache()) {
isolate->counters()->total_load_size()->Increment(source_length);
isolate->counters()->total_compile_size()->Increment(source_length);
- if (FLAG_use_strict) info->SetStrictMode(STRICT);
+ if (FLAG_use_strict) {
+ info->SetLanguageMode(
+ static_cast<LanguageMode>(info->language_mode() | STRICT));
+ }
// TODO(marja): FLAG_serialize_toplevel is not honoured and won't be; when the
// real code caching lands, streaming needs to be adapted to use it.
return CompileToplevel(info);
CompilationInfoWithZone info(script);
info.SetFunction(literal);
info.PrepareForCompilation(literal->scope());
- info.SetStrictMode(literal->scope()->strict_mode());
+ info.SetLanguageMode(literal->scope()->language_mode());
if (outer_info->will_serialize()) info.PrepareForSerializing();
Isolate* isolate = info.isolate();
bool is_eval() const { return GetFlag(kEval); }
bool is_global() const { return GetFlag(kGlobal); }
bool is_module() const { return GetFlag(kModule); }
- StrictMode strict_mode() const {
+ LanguageMode language_mode() const {
+ STATIC_ASSERT(LANGUAGE_END == 2);
return GetFlag(kStrictMode) ? STRICT : SLOPPY;
}
FunctionLiteral* function() const { return function_; }
bool this_has_uses() { return GetFlag(kThisHasUses); }
- void SetStrictMode(StrictMode strict_mode) {
- SetFlag(kStrictMode, strict_mode == STRICT);
+ void SetLanguageMode(LanguageMode language_mode) {
+ STATIC_ASSERT(LANGUAGE_END == 2);
+ SetFlag(kStrictMode, language_mode & STRICT);
}
void MarkAsNative() { SetFlag(kNative); }
// Compile a String source within a context for eval.
MUST_USE_RESULT static MaybeHandle<JSFunction> GetFunctionFromEval(
Handle<String> source, Handle<SharedFunctionInfo> outer_info,
- Handle<Context> context, StrictMode strict_mode,
+ Handle<Context> context, LanguageMode language_mode,
ParseRestriction restriction, int scope_position);
// Compile a String source within a context.
if (FunctionLiteral::NeedsHomeObject(property->value())) {
Unique<Name> name =
MakeUnique(isolate()->factory()->home_object_symbol());
- Node* store = NewNode(javascript()->StoreNamed(strict_mode(), name),
+ Node* store = NewNode(javascript()->StoreNamed(language_mode(), name),
value, receiver);
PrepareFrameState(store, BailoutId::None());
}
VisitForValue(property->value());
Node* value = environment()->Pop();
Unique<Name> name = MakeUnique(key->AsPropertyName());
- Node* store = NewNode(javascript()->StoreNamed(strict_mode(), name),
- literal, value);
+ Node* store =
+ NewNode(javascript()->StoreNamed(language_mode(), name),
+ literal, value);
PrepareFrameState(store, key->id());
} else {
VisitForEffect(property->value());
Node* key = environment()->Pop();
Node* receiver = environment()->Pop();
if (property->emit_store()) {
- Node* strict = jsgraph()->Constant(SLOPPY);
+ Node* language = jsgraph()->Constant(SLOPPY);
const Operator* op =
javascript()->CallRuntime(Runtime::kSetProperty, 4);
- NewNode(op, receiver, key, value, strict);
+ NewNode(op, receiver, key, value, language);
}
break;
}
VisitForValue(subexpr);
Node* value = environment()->Pop();
Node* index = jsgraph()->Constant(i);
- Node* store = NewNode(javascript()->StoreProperty(strict_mode()), literal,
+ Node* store = NewNode(javascript()->StoreProperty(language_mode()), literal,
index, value);
PrepareFrameState(store, expr->GetIdForElement(i));
}
value = environment()->Pop();
Unique<Name> name =
MakeUnique(property->key()->AsLiteral()->AsPropertyName());
- Node* store =
- NewNode(javascript()->StoreNamed(strict_mode(), name), object, value);
+ Node* store = NewNode(javascript()->StoreNamed(language_mode(), name),
+ object, value);
PrepareFrameState(store, bailout_id);
break;
}
Node* key = environment()->Pop();
Node* object = environment()->Pop();
value = environment()->Pop();
- Node* store = NewNode(javascript()->StoreProperty(strict_mode()), object,
- key, value);
+ Node* store = NewNode(javascript()->StoreProperty(language_mode()),
+ object, key, value);
PrepareFrameState(store, bailout_id);
break;
}
Node* object = environment()->Pop();
Unique<Name> name =
MakeUnique(property->key()->AsLiteral()->AsPropertyName());
- Node* store =
- NewNode(javascript()->StoreNamed(strict_mode(), name), object, value);
+ Node* store = NewNode(javascript()->StoreNamed(language_mode(), name),
+ object, value);
PrepareFrameState(store, expr->AssignmentId(),
ast_context()->GetStateCombine());
break;
case KEYED_PROPERTY: {
Node* key = environment()->Pop();
Node* object = environment()->Pop();
- Node* store = NewNode(javascript()->StoreProperty(strict_mode()), object,
- key, value);
+ Node* store = NewNode(javascript()->StoreProperty(language_mode()),
+ object, key, value);
PrepareFrameState(store, expr->AssignmentId(),
ast_context()->GetStateCombine());
break;
// provide a fully resolved callee and the corresponding receiver.
Node* function = GetFunctionClosure();
Node* receiver = environment()->Lookup(info()->scope()->receiver());
- Node* strict = jsgraph()->Constant(strict_mode());
+ Node* language = jsgraph()->Constant(language_mode());
Node* position = jsgraph()->Constant(info()->scope()->start_position());
const Operator* op =
javascript()->CallRuntime(Runtime::kResolvePossiblyDirectEval, 6);
Node* pair =
- NewNode(op, callee, source, function, receiver, strict, position);
+ NewNode(op, callee, source, function, receiver, language, position);
PrepareFrameState(pair, expr->EvalOrLookupId(),
OutputFrameStateCombine::PokeAt(arg_count + 1));
Node* new_callee = NewNode(common()->Projection(0), pair);
Node* object = environment()->Pop();
Unique<Name> name =
MakeUnique(property->key()->AsLiteral()->AsPropertyName());
- Node* store =
- NewNode(javascript()->StoreNamed(strict_mode(), name), object, value);
+ Node* store = NewNode(javascript()->StoreNamed(language_mode(), name),
+ object, value);
environment()->Push(value);
PrepareFrameState(store, expr->AssignmentId());
environment()->Pop();
case KEYED_PROPERTY: {
Node* key = environment()->Pop();
Node* object = environment()->Pop();
- Node* store = NewNode(javascript()->StoreProperty(strict_mode()), object,
- key, value);
+ Node* store = NewNode(javascript()->StoreProperty(language_mode()),
+ object, key, value);
environment()->Push(value);
PrepareFrameState(store, expr->AssignmentId());
environment()->Pop();
for (Handle<Object> obj : *globals()) data->set(array_index++, *obj);
int encoded_flags = DeclareGlobalsEvalFlag::encode(info()->is_eval()) |
DeclareGlobalsNativeFlag::encode(info()->is_native()) |
- DeclareGlobalsStrictMode::encode(strict_mode());
+ DeclareGlobalsLanguageMode::encode(language_mode());
Node* flags = jsgraph()->Constant(encoded_flags);
Node* pairs = jsgraph()->Constant(data);
const Operator* op = javascript()->CallRuntime(Runtime::kDeclareGlobals, 3);
// Delete of an unqualified identifier is only allowed in classic mode but
// deleting "this" is allowed in all language modes.
Variable* variable = expr->expression()->AsVariableProxy()->var();
- DCHECK(strict_mode() == SLOPPY || variable->is_this());
+ DCHECK(is_sloppy(language_mode()) || variable->is_this());
value = BuildVariableDelete(variable, expr->id(),
ast_context()->GetStateCombine());
} else if (expr->expression()->IsProperty()) {
VisitForValue(property->key());
Node* key = environment()->Pop();
Node* object = environment()->Pop();
- value = NewNode(javascript()->DeleteProperty(strict_mode()), object, key);
+ value = NewNode(javascript()->DeleteProperty(language_mode()), object, key);
PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine());
} else {
VisitForEffect(expr->expression());
}
-StrictMode AstGraphBuilder::strict_mode() const {
- return info()->strict_mode();
+LanguageMode AstGraphBuilder::language_mode() const {
+ return info()->language_mode();
}
// Sloppy mode functions and builtins need to replace the receiver with the
// global proxy when called as functions (without an explicit receiver
// object). Otherwise there is nothing left to do here.
- if (strict_mode() != SLOPPY || info()->is_native()) return receiver;
+ if (is_strict(language_mode()) || info()->is_native()) return receiver;
// There is no need to perform patching if the receiver is never used. Note
// that scope predicates are purely syntactical, a call to eval might still
// Global var, const, or let variable.
Node* global = BuildLoadGlobalObject();
Node* name = jsgraph()->Constant(variable->name());
- const Operator* op = javascript()->DeleteProperty(strict_mode());
+ const Operator* op = javascript()->DeleteProperty(language_mode());
Node* result = NewNode(op, global, name);
PrepareFrameState(result, bailout_id, state_combine);
return result;
// Global var, const, or let variable.
Node* global = BuildLoadGlobalObject();
Unique<Name> name = MakeUnique(variable->name());
- const Operator* op = javascript()->StoreNamed(strict_mode(), name);
+ const Operator* op = javascript()->StoreNamed(language_mode(), name);
Node* store = NewNode(op, global, value);
PrepareFrameState(store, bailout_id, combine);
return store;
// Non-initializing assignments to legacy const is
// - exception in strict mode.
// - ignored in sloppy mode.
- if (strict_mode() == STRICT) {
+ if (is_strict(language_mode())) {
return BuildThrowConstAssignError(bailout_id);
}
return value;
// Non-initializing assignments to legacy const is
// - exception in strict mode.
// - ignored in sloppy mode.
- if (strict_mode() == STRICT) {
+ if (is_strict(language_mode())) {
return BuildThrowConstAssignError(bailout_id);
}
return value;
case Variable::LOOKUP: {
// Dynamic lookup of context variable (anywhere in the chain).
Node* name = jsgraph()->Constant(variable->name());
- Node* strict = jsgraph()->Constant(strict_mode());
+ Node* language = jsgraph()->Constant(language_mode());
// TODO(mstarzinger): Use Runtime::kInitializeLegacyConstLookupSlot for
// initializations of const declarations.
const Operator* op =
javascript()->CallRuntime(Runtime::kStoreLookupSlot, 4);
- Node* store = NewNode(op, value, current_context(), name, strict);
+ Node* store = NewNode(op, value, current_context(), name, language);
PrepareFrameState(store, bailout_id, combine);
return store;
}
ContextScope* execution_context() const { return execution_context_; }
CommonOperatorBuilder* common() const { return jsgraph_->common(); }
CompilationInfo* info() const { return info_; }
- StrictMode strict_mode() const;
+ LanguageMode language_mode() const;
JSGraph* jsgraph() { return jsgraph_; }
Graph* graph() { return jsgraph_->graph(); }
Zone* graph_zone() { return graph()->zone(); }
void JSGenericLowering::LowerJSStoreProperty(Node* node) {
- StrictMode strict_mode = OpParameter<StrictMode>(node);
- Callable callable = CodeFactory::KeyedStoreIC(isolate(), strict_mode);
+ LanguageMode language_mode = OpParameter<LanguageMode>(node);
+ Callable callable = CodeFactory::KeyedStoreIC(isolate(), language_mode);
ReplaceWithStubCall(node, callable, CallDescriptor::kPatchableCallSite);
}
void JSGenericLowering::LowerJSStoreNamed(Node* node) {
const StoreNamedParameters& p = StoreNamedParametersOf(node->op());
- Callable callable = CodeFactory::StoreIC(isolate(), p.strict_mode());
+ Callable callable = CodeFactory::StoreIC(isolate(), p.language_mode());
PatchInsertInput(node, 1, jsgraph()->HeapConstant(p.name()));
ReplaceWithStubCall(node, callable, CallDescriptor::kPatchableCallSite);
}
void JSGenericLowering::LowerJSDeleteProperty(Node* node) {
- StrictMode strict_mode = OpParameter<StrictMode>(node);
+ LanguageMode language_mode = OpParameter<LanguageMode>(node);
ReplaceWithBuiltinCall(node, Builtins::DELETE, 3);
- PatchInsertInput(node, 4, jsgraph()->SmiConstant(strict_mode));
+ PatchInsertInput(node, 4, jsgraph()->SmiConstant(language_mode));
}
CHECK(Compiler::ParseAndAnalyze(&info));
CHECK(Compiler::EnsureDeoptimizationSupport(&info));
- if (info.scope()->arguments() != NULL && info.strict_mode() != STRICT) {
+ if (info.scope()->arguments() != NULL && is_sloppy(info.language_mode())) {
// For now do not inline functions that use their arguments array.
SmartArrayPointer<char> name = function->shared()->DebugName()->ToCString();
if (FLAG_trace_turbo_inlining) {
bool operator==(StoreNamedParameters const& lhs,
StoreNamedParameters const& rhs) {
- return lhs.strict_mode() == rhs.strict_mode() && lhs.name() == rhs.name();
+ return lhs.language_mode() == rhs.language_mode() && lhs.name() == rhs.name();
}
size_t hash_value(StoreNamedParameters const& p) {
- return base::hash_combine(p.strict_mode(), p.name());
+ return base::hash_combine(p.language_mode(), p.name());
}
std::ostream& operator<<(std::ostream& os, StoreNamedParameters const& p) {
- return os << p.strict_mode() << ", " << Brief(*p.name().handle());
+ return os << p.language_mode() << ", " << Brief(*p.name().handle());
}
CACHED_OP_LIST(CACHED)
#undef CACHED
- template <StrictMode kStrictMode>
- struct StorePropertyOperator FINAL : public Operator1<StrictMode> {
+ template <LanguageMode kLanguageMode>
+ struct StorePropertyOperator FINAL : public Operator1<LanguageMode> {
StorePropertyOperator()
- : Operator1<StrictMode>(IrOpcode::kJSStoreProperty,
- Operator::kNoProperties, "JSStoreProperty", 3,
- 1, 1, 0, 1, 0, kStrictMode) {}
+ : Operator1<LanguageMode>(IrOpcode::kJSStoreProperty,
+ Operator::kNoProperties, "JSStoreProperty", 3,
+ 1, 1, 0, 1, 0, kLanguageMode) {}
};
StorePropertyOperator<SLOPPY> kStorePropertySloppyOperator;
StorePropertyOperator<STRICT> kStorePropertyStrictOperator;
}
-const Operator* JSOperatorBuilder::StoreProperty(StrictMode strict_mode) {
- switch (strict_mode) {
- case SLOPPY:
- return &cache_.kStorePropertySloppyOperator;
- case STRICT:
- return &cache_.kStorePropertyStrictOperator;
+const Operator* JSOperatorBuilder::StoreProperty(LanguageMode language_mode) {
+ if (is_strict(language_mode)) {
+ return &cache_.kStorePropertyStrictOperator;
+ } else {
+ return &cache_.kStorePropertySloppyOperator;
}
UNREACHABLE();
return nullptr;
}
-const Operator* JSOperatorBuilder::StoreNamed(StrictMode strict_mode,
+const Operator* JSOperatorBuilder::StoreNamed(LanguageMode language_mode,
const Unique<Name>& name) {
- StoreNamedParameters parameters(strict_mode, name);
+ StoreNamedParameters parameters(language_mode, name);
return new (zone()) Operator1<StoreNamedParameters>( // --
IrOpcode::kJSStoreNamed, Operator::kNoProperties, // opcode
"JSStoreNamed", // name
}
-const Operator* JSOperatorBuilder::DeleteProperty(StrictMode strict_mode) {
- return new (zone()) Operator1<StrictMode>( // --
+const Operator* JSOperatorBuilder::DeleteProperty(LanguageMode language_mode) {
+ return new (zone()) Operator1<LanguageMode>( // --
IrOpcode::kJSDeleteProperty, Operator::kNoProperties, // opcode
"JSDeleteProperty", // name
2, 1, 1, 1, 1, 0, // counts
- strict_mode); // parameter
+ language_mode); // parameter
}
// used as a parameter by JSStoreNamed operators.
class StoreNamedParameters FINAL {
public:
- StoreNamedParameters(StrictMode strict_mode, const Unique<Name>& name)
- : strict_mode_(strict_mode), name_(name) {}
+ StoreNamedParameters(LanguageMode language_mode, const Unique<Name>& name)
+ : language_mode_(language_mode), name_(name) {}
- StrictMode strict_mode() const { return strict_mode_; }
+ LanguageMode language_mode() const { return language_mode_; }
const Unique<Name>& name() const { return name_; }
private:
- const StrictMode strict_mode_;
+ const LanguageMode language_mode_;
const Unique<Name> name_;
};
const VectorSlotPair& feedback,
ContextualMode contextual_mode = NOT_CONTEXTUAL);
- const Operator* StoreProperty(StrictMode strict_mode);
- const Operator* StoreNamed(StrictMode strict_mode, const Unique<Name>& name);
+ const Operator* StoreProperty(LanguageMode language_mode);
+ const Operator* StoreNamed(LanguageMode language_mode,
+ const Unique<Name>& name);
- const Operator* DeleteProperty(StrictMode strict_mode);
+ const Operator* DeleteProperty(LanguageMode language_mode);
const Operator* HasProperty();
return kHeaderSize + index * kPointerSize - kHeapObjectTag;
}
- static int FunctionMapIndex(StrictMode strict_mode, FunctionKind kind) {
+ static int FunctionMapIndex(LanguageMode language_mode, FunctionKind kind) {
if (IsGeneratorFunction(kind)) {
- return strict_mode == SLOPPY ? SLOPPY_GENERATOR_FUNCTION_MAP_INDEX
- : STRICT_GENERATOR_FUNCTION_MAP_INDEX;
+ return is_strict(language_mode) ? STRICT_GENERATOR_FUNCTION_MAP_INDEX
+ : SLOPPY_GENERATOR_FUNCTION_MAP_INDEX;
}
if (IsArrowFunction(kind) || IsConciseMethod(kind)) {
- return strict_mode == SLOPPY
- ? SLOPPY_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX
- : STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX;
+ return is_strict(language_mode)
+ ? STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX
+ : SLOPPY_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX;
}
- return strict_mode == SLOPPY ? SLOPPY_FUNCTION_MAP_INDEX
- : STRICT_FUNCTION_MAP_INDEX;
+ return is_strict(language_mode) ? STRICT_FUNCTION_MAP_INDEX
+ : SLOPPY_FUNCTION_MAP_INDEX;
}
static const int kSize = kHeaderSize + NATIVE_CONTEXT_SLOTS * kPointerSize;
}
MUST_USE_RESULT virtual MaybeHandle<Object> Delete(
- Handle<JSObject> obj, uint32_t key, StrictMode strict_mode) OVERRIDE = 0;
+ Handle<JSObject> obj, uint32_t key,
+ LanguageMode language_mode) OVERRIDE = 0;
static void CopyElementsImpl(FixedArrayBase* from, uint32_t from_start,
FixedArrayBase* to, ElementsKind from_kind,
}
static Handle<Object> DeleteCommon(Handle<JSObject> obj, uint32_t key,
- StrictMode strict_mode) {
+ LanguageMode language_mode) {
DCHECK(obj->HasFastSmiOrObjectElements() ||
obj->HasFastDoubleElements() ||
obj->HasFastArgumentsElements());
}
virtual MaybeHandle<Object> Delete(Handle<JSObject> obj, uint32_t key,
- StrictMode strict_mode) FINAL {
- return DeleteCommon(obj, key, strict_mode);
+ LanguageMode language_mode) FINAL {
+ return DeleteCommon(obj, key, language_mode);
}
static bool HasElementImpl(
}
MUST_USE_RESULT virtual MaybeHandle<Object> Delete(
- Handle<JSObject> obj, uint32_t key, StrictMode strict_mode) FINAL {
+ Handle<JSObject> obj, uint32_t key, LanguageMode language_mode) FINAL {
// External arrays always ignore deletes.
return obj->GetIsolate()->factory()->true_value();
}
}
MUST_USE_RESULT static MaybeHandle<Object> DeleteCommon(
- Handle<JSObject> obj, uint32_t key, StrictMode strict_mode) {
+ Handle<JSObject> obj, uint32_t key, LanguageMode language_mode) {
Isolate* isolate = obj->GetIsolate();
Handle<FixedArray> backing_store(FixedArray::cast(obj->elements()),
isolate);
Handle<Object> result =
SeededNumberDictionary::DeleteProperty(dictionary, entry);
if (*result == *isolate->factory()->false_value()) {
- if (strict_mode == STRICT) {
+ if (is_strict(language_mode)) {
// Deleting a non-configurable property in strict mode.
Handle<Object> name = isolate->factory()->NewNumberFromUint(key);
Handle<Object> args[2] = { name, obj };
ElementsKindTraits<DICTIONARY_ELEMENTS> >;
MUST_USE_RESULT virtual MaybeHandle<Object> Delete(
- Handle<JSObject> obj, uint32_t key, StrictMode strict_mode) FINAL {
- return DeleteCommon(obj, key, strict_mode);
+ Handle<JSObject> obj, uint32_t key, LanguageMode language_mode) FINAL {
+ return DeleteCommon(obj, key, language_mode);
}
MUST_USE_RESULT static MaybeHandle<Object> GetImpl(
}
MUST_USE_RESULT virtual MaybeHandle<Object> Delete(
- Handle<JSObject> obj, uint32_t key, StrictMode strict_mode) FINAL {
+ Handle<JSObject> obj, uint32_t key, LanguageMode language_mode) FINAL {
Isolate* isolate = obj->GetIsolate();
Handle<FixedArray> parameter_map(FixedArray::cast(obj->elements()));
Handle<Object> probe = GetParameterMapArg(obj, parameter_map, key);
} else {
Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1)));
if (arguments->IsDictionary()) {
- return DictionaryElementsAccessor::DeleteCommon(obj, key, strict_mode);
+ return DictionaryElementsAccessor::DeleteCommon(obj, key,
+ language_mode);
} else {
// It's difficult to access the version of DeleteCommon that is declared
// in the templatized super class, call the concrete implementation in
// the class for the most generalized ElementsKind subclass.
return FastHoleyObjectElementsAccessor::DeleteCommon(obj, key,
- strict_mode);
+ language_mode);
}
}
return isolate->factory()->true_value();
// Deletes an element in an object, returning a new elements backing store.
MUST_USE_RESULT virtual MaybeHandle<Object> Delete(
- Handle<JSObject> holder, uint32_t key, StrictMode strict_mode) = 0;
+ Handle<JSObject> holder, uint32_t key, LanguageMode language_mode) = 0;
// If kCopyToEnd is specified as the copy_size to CopyElements, it copies all
// of elements from source after source_start to the destination array.
// In sloppy mode, convert receiver.
if (convert_receiver && !receiver->IsJSReceiver() &&
- !func->shared()->native() &&
- func->shared()->strict_mode() == SLOPPY) {
+ !func->shared()->native() && is_sloppy(func->shared()->language_mode())) {
if (receiver->IsUndefined() || receiver->IsNull()) {
receiver = handle(func->global_proxy());
DCHECK(!receiver->IsJSBuiltinsObject());
MaybeHandle<Code> code) {
Handle<Context> context(isolate()->native_context());
Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name, code);
- DCHECK((info->strict_mode() == SLOPPY) &&
+ DCHECK(is_sloppy(info->language_mode()) &&
(map.is_identical_to(isolate()->sloppy_function_map()) ||
map.is_identical_to(
isolate()->sloppy_function_without_prototype_map()) ||
Handle<SharedFunctionInfo> info,
Handle<Context> context,
PretenureFlag pretenure) {
- int map_index = Context::FunctionMapIndex(info->strict_mode(), info->kind());
+ int map_index =
+ Context::FunctionMapIndex(info->language_mode(), info->kind());
Handle<Map> map(Map::cast(context->native_context()->get(map_index)));
Handle<JSFunction> result = NewFunction(map, info, context, pretenure);
Handle<JSObject> Factory::NewArgumentsObject(Handle<JSFunction> callee,
int length) {
- bool strict_mode_callee = callee->shared()->strict_mode() == STRICT;
+ bool strict_mode_callee = is_strict(callee->shared()->language_mode());
Handle<Map> map = strict_mode_callee ? isolate()->strict_arguments_map()
: isolate()->sloppy_arguments_map();
void FullCodeGenerator::CallStoreIC(TypeFeedbackId id) {
- Handle<Code> ic = CodeFactory::StoreIC(isolate(), strict_mode()).code();
+ Handle<Code> ic = CodeFactory::StoreIC(isolate(), language_mode()).code();
CallIC(ic, id);
}
int FullCodeGenerator::DeclareGlobalsFlags() {
- DCHECK(DeclareGlobalsStrictMode::is_valid(strict_mode()));
+ DCHECK(DeclareGlobalsLanguageMode::is_valid(language_mode()));
return DeclareGlobalsEvalFlag::encode(is_eval()) |
- DeclareGlobalsNativeFlag::encode(is_native()) |
- DeclareGlobalsStrictMode::encode(strict_mode());
+ DeclareGlobalsNativeFlag::encode(is_native()) |
+ DeclareGlobalsLanguageMode::encode(language_mode());
}
// Shall an error be thrown if assignment with 'op' operation is perfomed
// on this variable in given language mode?
static bool IsSignallingAssignmentToConst(Variable* var, Token::Value op,
- StrictMode strict_mode) {
+ LanguageMode language_mode) {
if (var->mode() == CONST) return op != Token::INIT_CONST;
if (var->mode() == CONST_LEGACY) {
- return strict_mode == STRICT && op != Token::INIT_CONST_LEGACY;
+ return is_strict(language_mode) && op != Token::INIT_CONST_LEGACY;
}
return false;
Handle<Script> script() { return info_->script(); }
bool is_eval() { return info_->is_eval(); }
bool is_native() { return info_->is_native(); }
- StrictMode strict_mode() { return function()->strict_mode(); }
+ LanguageMode language_mode() { return function()->language_mode(); }
FunctionLiteral* function() { return info_->function(); }
Scope* scope() { return scope_; }
// The Strict Mode (ECMA-262 5th edition, 4.2.2).
-enum StrictMode { SLOPPY, STRICT };
+enum LanguageMode {
+ // LanguageMode is expressed as a bitmask. Descriptions of the bits:
+ STRICT = 1 << 0,
+ LANGUAGE_END,
+ // Shorthands for some common language modes.
+ SLOPPY = 0
+};
+
+inline bool is_strict(LanguageMode language_mode) {
+ return language_mode & STRICT;
+}
+
+inline bool is_sloppy(LanguageMode language_mode) {
+ return (language_mode & STRICT) == 0;
+}
+
+inline bool is_valid_language_mode(int language_mode) {
+ return language_mode == SLOPPY || language_mode == STRICT;
+}
// Mask for the sign bit in a smi.
const intptr_t kSmiSignMask = kIntptrSignBit;
public:
DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(HStoreNamedGeneric, HValue*,
Handle<String>, HValue*,
- StrictMode);
+ LanguageMode);
HValue* object() const { return OperandAt(0); }
HValue* value() const { return OperandAt(1); }
HValue* context() const { return OperandAt(2); }
Handle<String> name() const { return name_; }
- StrictMode strict_mode() const { return strict_mode_; }
+ LanguageMode language_mode() const { return language_mode_; }
std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric)
private:
- HStoreNamedGeneric(HValue* context,
- HValue* object,
- Handle<String> name,
- HValue* value,
- StrictMode strict_mode)
- : name_(name),
- strict_mode_(strict_mode) {
+ HStoreNamedGeneric(HValue* context, HValue* object, Handle<String> name,
+ HValue* value, LanguageMode language_mode)
+ : name_(name), language_mode_(language_mode) {
SetOperandAt(0, object);
SetOperandAt(1, value);
SetOperandAt(2, context);
}
Handle<String> name_;
- StrictMode strict_mode_;
+ LanguageMode language_mode_;
};
class HStoreKeyedGeneric FINAL : public HTemplateInstruction<4> {
public:
DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(HStoreKeyedGeneric, HValue*,
- HValue*, HValue*, StrictMode);
+ HValue*, HValue*, LanguageMode);
HValue* object() const { return OperandAt(0); }
HValue* key() const { return OperandAt(1); }
HValue* value() const { return OperandAt(2); }
HValue* context() const { return OperandAt(3); }
- StrictMode strict_mode() const { return strict_mode_; }
+ LanguageMode language_mode() const { return language_mode_; }
Representation RequiredInputRepresentation(int index) OVERRIDE {
// tagged[tagged] = tagged
DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric)
private:
- HStoreKeyedGeneric(HValue* context,
- HValue* object,
- HValue* key,
- HValue* value,
- StrictMode strict_mode)
- : strict_mode_(strict_mode) {
+ HStoreKeyedGeneric(HValue* context, HValue* object, HValue* key,
+ HValue* value, LanguageMode language_mode)
+ : language_mode_(language_mode) {
SetOperandAt(0, object);
SetOperandAt(1, key);
SetOperandAt(2, value);
SetAllSideEffects();
}
- StrictMode strict_mode_;
+ LanguageMode language_mode_;
};
bool is_concise_method() const { return IsConciseMethod(kind()); }
bool is_default_constructor() const { return IsDefaultConstructor(kind()); }
FunctionKind kind() const { return FunctionKindField::decode(bit_field_); }
- StrictMode strict_mode() const { return StrictModeField::decode(bit_field_); }
+ LanguageMode language_mode() const {
+ return LanguageModeField::decode(bit_field_);
+ }
private:
HFunctionLiteral(HValue* context, Handle<SharedFunctionInfo> shared,
bit_field_(FunctionKindField::encode(shared->kind()) |
PretenureField::encode(pretenure) |
HasNoLiteralsField::encode(shared->num_literals() == 0) |
- StrictModeField::encode(shared->strict_mode())) {
+ LanguageModeField::encode(shared->language_mode())) {
SetOperandAt(0, context);
set_representation(Representation::Tagged());
SetChangesFlag(kNewSpacePromotion);
class FunctionKindField : public BitField<FunctionKind, 0, 4> {};
class PretenureField : public BitField<bool, 5, 1> {};
class HasNoLiteralsField : public BitField<bool, 6, 1> {};
- class StrictModeField : public BitField<StrictMode, 7, 1> {};
+ STATIC_ASSERT(LANGUAGE_END == 2);
+ class LanguageModeField : public BitField<LanguageMode, 7, 1> {};
Handle<SharedFunctionInfo> shared_info_;
uint32_t bit_field_;
Handle<JSFunction> f = Handle<JSFunction>::cast(
HConstant::cast(function)->handle(isolate()));
SharedFunctionInfo* shared = f->shared();
- if (shared->strict_mode() == STRICT || shared->native()) return object;
+ if (is_strict(shared->language_mode()) || shared->native()) return object;
}
return Add<HWrapReceiver>(object, function);
}
static bool NeedsWrappingFor(Type* type, Handle<JSFunction> target) {
return type->Is(Type::NumberOrString()) &&
- target->shared()->strict_mode() == SLOPPY &&
- !target->shared()->native();
+ is_sloppy(target->shared()->language_mode()) &&
+ !target->shared()->native();
}
HValue* global_object = Add<HLoadNamedField>(
context(), nullptr,
HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX));
- HStoreNamedGeneric* instr =
- Add<HStoreNamedGeneric>(global_object, var->name(),
- value, function_strict_mode());
+ HStoreNamedGeneric* instr = Add<HStoreNamedGeneric>(
+ global_object, var->name(), value, function_language_mode());
USE(instr);
DCHECK(instr->HasObservableSideEffects());
Add<HSimulate>(ast_id, REMOVABLE_SIMULATE);
}
return result;
} else {
- return New<HStoreNamedGeneric>(object, name, value, function_strict_mode());
+ return New<HStoreNamedGeneric>(object, name, value,
+ function_language_mode());
}
}
}
return result;
} else {
- return New<HStoreKeyedGeneric>(object, key, value, function_strict_mode());
+ return New<HStoreKeyedGeneric>(object, key, value,
+ function_language_mode());
}
}
HValue* HOptimizedGraphBuilder::ImplicitReceiverFor(HValue* function,
Handle<JSFunction> target) {
SharedFunctionInfo* shared = target->shared();
- if (shared->strict_mode() == SLOPPY && !shared->native()) {
+ if (is_sloppy(shared->language_mode()) && !shared->native()) {
// Cannot embed a direct reference to the global proxy
// as is it dropped on deserialization.
CHECK(!isolate()->serializer_enabled());
HValue* key = Pop();
HValue* obj = Pop();
HValue* function = AddLoadJSBuiltin(Builtins::DELETE);
- Add<HPushArguments>(obj, key, Add<HConstant>(function_strict_mode()));
+ Add<HPushArguments>(obj, key, Add<HConstant>(function_language_mode()));
// TODO(olivf) InvokeFunction produces a check for the parameter count,
// even though we are certain to pass the correct number of arguments here.
HInstruction* instr = New<HInvokeFunction>(function, 3);
Handle<FixedArray> array =
isolate()->factory()->NewFixedArray(globals_.length(), TENURED);
for (int i = 0; i < globals_.length(); ++i) array->set(i, *globals_.at(i));
- int flags = DeclareGlobalsEvalFlag::encode(current_info()->is_eval()) |
+ int flags =
+ DeclareGlobalsEvalFlag::encode(current_info()->is_eval()) |
DeclareGlobalsNativeFlag::encode(current_info()->is_native()) |
- DeclareGlobalsStrictMode::encode(current_info()->strict_mode());
+ DeclareGlobalsLanguageMode::encode(current_info()->language_mode());
Add<HDeclareGlobals>(array, flags);
globals_.Rewind(0);
}
void ClearInlinedTestContext() {
function_state()->ClearInlinedTestContext();
}
- StrictMode function_strict_mode() {
- return function_state()->compilation_info()->strict_mode();
+ LanguageMode function_language_mode() {
+ return function_state()->compilation_info()->language_mode();
}
// Generators for inline runtime functions.
// Sloppy mode functions and builtins need to replace the receiver with the
// global proxy when called as functions (without an explicit receiver
// object).
- if (info->strict_mode() == SLOPPY && !info->is_native()) {
+ if (is_sloppy(info->language_mode()) && !info->is_native()) {
Label ok;
// +1 for return address.
int receiver_offset = (info->scope()->num_parameters() + 1) * kPointerSize;
// The stub will rewrite receiver and parameter count if the previous
// stack frame was an arguments adapter frame.
ArgumentsAccessStub::Type type;
- if (strict_mode() == STRICT) {
+ if (is_strict(language_mode())) {
type = ArgumentsAccessStub::NEW_STRICT;
} else if (function()->has_duplicate_parameters()) {
type = ArgumentsAccessStub::NEW_SLOPPY_SLOW;
!pretenure &&
scope()->is_function_scope() &&
info->num_literals() == 0) {
- FastNewClosureStub stub(isolate(), info->strict_mode(), info->kind());
+ FastNewClosureStub stub(isolate(), info->language_mode(), info->kind());
__ mov(ebx, Immediate(info));
__ CallStub(&stub);
} else {
VisitForStackValue(value);
if (property->emit_store()) {
EmitSetHomeObjectIfNeeded(value, 2);
- __ push(Immediate(Smi::FromInt(SLOPPY))); // Strict mode
+ __ push(Immediate(Smi::FromInt(SLOPPY))); // Language mode
__ CallRuntime(Runtime::kSetProperty, 4);
} else {
__ Drop(3);
__ pop(StoreDescriptor::ReceiverRegister()); // Receiver.
__ pop(StoreDescriptor::ValueRegister()); // Restore value.
Handle<Code> ic =
- CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code();
+ CodeFactory::KeyedStoreIC(isolate(), language_mode()).code();
CallIC(ic);
break;
}
__ push(eax); // Value.
__ push(esi); // Context.
__ push(Immediate(var->name()));
- __ push(Immediate(Smi::FromInt(strict_mode())));
+ __ push(Immediate(Smi::FromInt(language_mode())));
__ CallRuntime(Runtime::kStoreLookupSlot, 4);
} else {
// Assignment to var or initializing assignment to let/const in harmony
}
EmitStoreToStackLocalOrContextSlot(var, location);
}
- } else if (IsSignallingAssignmentToConst(var, op, strict_mode())) {
+ } else if (IsSignallingAssignmentToConst(var, op, language_mode())) {
__ CallRuntime(Runtime::kThrowConstAssignError, 0);
}
}
__ push(Immediate(key->value()));
__ push(eax);
- __ CallRuntime((strict_mode() == STRICT ? Runtime::kStoreToSuper_Strict
- : Runtime::kStoreToSuper_Sloppy),
+ __ CallRuntime((is_strict(language_mode()) ? Runtime::kStoreToSuper_Strict
+ : Runtime::kStoreToSuper_Sloppy),
4);
}
// stack : receiver ('this'), home_object, key
__ push(eax);
- __ CallRuntime((strict_mode() == STRICT ? Runtime::kStoreKeyedToSuper_Strict
- : Runtime::kStoreKeyedToSuper_Sloppy),
- 4);
+ __ CallRuntime(
+ (is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict
+ : Runtime::kStoreKeyedToSuper_Sloppy),
+ 4);
}
DCHECK(StoreDescriptor::ValueRegister().is(eax));
// Record source code position before IC call.
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());
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
// Push the receiver of the enclosing function.
__ push(Operand(ebp, (2 + info_->scope()->num_parameters()) * kPointerSize));
// 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(Immediate(Smi::FromInt(scope()->start_position())));
if (property != NULL) {
VisitForStackValue(property->obj());
VisitForStackValue(property->key());
- __ push(Immediate(Smi::FromInt(strict_mode())));
+ __ push(Immediate(Smi::FromInt(language_mode())));
__ 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.
- DCHECK(strict_mode() == SLOPPY || var->is_this());
+ DCHECK(is_sloppy(language_mode()) || var->is_this());
if (var->IsUnallocated()) {
__ push(GlobalObjectOperand());
__ push(Immediate(var->name()));
__ pop(StoreDescriptor::NameRegister());
__ pop(StoreDescriptor::ReceiverRegister());
Handle<Code> ic =
- CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code();
+ CodeFactory::KeyedStoreIC(isolate(), language_mode()).code();
CallIC(ic, expr->CountStoreFeedbackId());
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
if (expr->is_postfix()) {
// Sloppy mode functions and builtins need to replace the receiver with the
// global proxy when called as functions (without an explicit receiver
// object).
- if (info_->this_has_uses() &&
- info_->strict_mode() == SLOPPY &&
+ if (info_->this_has_uses() && is_sloppy(info_->language_mode()) &&
!info_->is_native()) {
Label ok;
// +1 for return address.
DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister()));
__ 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);
}
DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister()));
Handle<Code> ic =
- CodeFactory::KeyedStoreIC(isolate(), instr->strict_mode()).code();
+ CodeFactory::KeyedStoreIC(isolate(), instr->language_mode()).code();
CallCode(ic, RelocInfo::CODE_TARGET, instr);
}
// space for nested functions that don't need literals cloning.
bool pretenure = instr->hydrogen()->pretenure();
if (!pretenure && instr->hydrogen()->has_no_literals()) {
- FastNewClosureStub stub(isolate(), instr->hydrogen()->strict_mode(),
+ FastNewClosureStub stub(isolate(), instr->hydrogen()->language_mode(),
instr->hydrogen()->kind());
__ mov(ebx, Immediate(instr->hydrogen()->shared_info()));
CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
#undef DECLARE_DO
private:
- StrictMode strict_mode() const { return info()->strict_mode(); }
+ LanguageMode language_mode() const { return info()->language_mode(); }
Scope* scope() const { return scope_; }
void PrintDataTo(StringStream* stream) OVERRIDE;
Handle<Object> name() const { return hydrogen()->name(); }
- StrictMode strict_mode() { return hydrogen()->strict_mode(); }
+ LanguageMode language_mode() { return hydrogen()->language_mode(); }
};
void PrintDataTo(StringStream* stream) OVERRIDE;
- StrictMode strict_mode() { return hydrogen()->strict_mode(); }
+ LanguageMode language_mode() { return hydrogen()->language_mode(); }
};
void KeyedStoreIC::GenerateMegamorphic(MacroAssembler* masm,
- StrictMode strict_mode) {
+ LanguageMode language_mode) {
// ---------- S t a t e --------------
// -- r0 : value
// -- r1 : key
// r0: value.
// r1: key.
// r2: receiver.
- PropertyICCompiler::GenerateRuntimeSetProperty(masm, strict_mode);
+ PropertyICCompiler::GenerateRuntimeSetProperty(masm, language_mode);
// Never returns to here.
__ bind(&maybe_name_key);
#define __ ACCESS_MASM(masm)
-void PropertyICCompiler::GenerateRuntimeSetProperty(MacroAssembler* masm,
- StrictMode strict_mode) {
+void PropertyICCompiler::GenerateRuntimeSetProperty(
+ MacroAssembler* masm, LanguageMode language_mode) {
__ Push(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister(),
StoreDescriptor::ValueRegister());
- __ mov(r0, Operand(Smi::FromInt(strict_mode)));
+ __ mov(r0, Operand(Smi::FromInt(language_mode)));
__ Push(r0);
// Do tail-call to runtime routine.
void KeyedStoreIC::GenerateMegamorphic(MacroAssembler* masm,
- StrictMode strict_mode) {
+ LanguageMode language_mode) {
ASM_LOCATION("KeyedStoreIC::GenerateMegamorphic");
Label slow;
Label array;
// x0: value
// x1: key
// x2: receiver
- PropertyICCompiler::GenerateRuntimeSetProperty(masm, strict_mode);
+ PropertyICCompiler::GenerateRuntimeSetProperty(masm, language_mode);
// Never returns to here.
__ bind(&maybe_name_key);
#define __ ACCESS_MASM(masm)
-void PropertyICCompiler::GenerateRuntimeSetProperty(MacroAssembler* masm,
- StrictMode strict_mode) {
+void PropertyICCompiler::GenerateRuntimeSetProperty(
+ MacroAssembler* masm, LanguageMode language_mode) {
ASM_LOCATION("PropertyICCompiler::GenerateRuntimeSetProperty");
__ Push(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister(),
StoreDescriptor::ValueRegister());
- __ Mov(x10, Smi::FromInt(strict_mode));
+ __ Mov(x10, Smi::FromInt(language_mode));
__ Push(x10);
// Do tail-call to runtime routine.
#define __ ACCESS_MASM(masm)
-void PropertyICCompiler::GenerateRuntimeSetProperty(MacroAssembler* masm,
- StrictMode strict_mode) {
+void PropertyICCompiler::GenerateRuntimeSetProperty(
+ MacroAssembler* masm, LanguageMode language_mode) {
// Return address is on the stack.
DCHECK(!ebx.is(StoreDescriptor::ReceiverRegister()) &&
!ebx.is(StoreDescriptor::NameRegister()) &&
__ push(StoreDescriptor::ReceiverRegister());
__ push(StoreDescriptor::NameRegister());
__ push(StoreDescriptor::ValueRegister());
- __ push(Immediate(Smi::FromInt(strict_mode)));
+ __ push(Immediate(Smi::FromInt(language_mode)));
__ push(ebx); // return address
// Do tail-call to runtime routine.
void KeyedStoreIC::GenerateMegamorphic(MacroAssembler* masm,
- StrictMode strict_mode) {
+ LanguageMode language_mode) {
// Return address is on the stack.
Label slow, fast_object, fast_object_grow;
Label fast_double, fast_double_grow;
// Slow case: call runtime.
__ bind(&slow);
- PropertyICCompiler::GenerateRuntimeSetProperty(masm, strict_mode);
+ PropertyICCompiler::GenerateRuntimeSetProperty(masm, language_mode);
// Never returns to here.
__ bind(&maybe_name_key);
Handle<Code> PropertyICCompiler::ComputeKeyedStoreMonomorphic(
- Handle<Map> receiver_map, StrictMode strict_mode,
+ Handle<Map> receiver_map, LanguageMode language_mode,
KeyedAccessStoreMode store_mode) {
Isolate* isolate = receiver_map->GetIsolate();
ExtraICState extra_state =
- KeyedStoreIC::ComputeExtraICState(strict_mode, store_mode);
+ KeyedStoreIC::ComputeExtraICState(language_mode, store_mode);
Code::Flags flags =
Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, extra_state);
Handle<Code> PropertyICCompiler::ComputeKeyedStorePolymorphic(
MapHandleList* receiver_maps, KeyedAccessStoreMode store_mode,
- StrictMode strict_mode) {
+ LanguageMode language_mode) {
Isolate* isolate = receiver_maps->at(0)->GetIsolate();
DCHECK(store_mode == STANDARD_STORE ||
store_mode == STORE_AND_GROW_NO_TRANSITION ||
Handle<PolymorphicCodeCache> cache =
isolate->factory()->polymorphic_code_cache();
ExtraICState extra_state =
- KeyedStoreIC::ComputeExtraICState(strict_mode, store_mode);
+ KeyedStoreIC::ComputeExtraICState(language_mode, store_mode);
Code::Flags flags =
Code::ComputeFlags(Code::KEYED_STORE_IC, POLYMORPHIC, extra_state);
Handle<Object> probe = cache->Lookup(receiver_maps, flags);
Handle<Code> PropertyICCompiler::CompileStoreGeneric(Code::Flags flags) {
ExtraICState extra_state = Code::ExtractExtraICStateFromFlags(flags);
- StrictMode strict_mode = StoreIC::GetStrictMode(extra_state);
- GenerateRuntimeSetProperty(masm(), strict_mode);
+ LanguageMode language_mode = StoreIC::GetLanguageMode(extra_state);
+ GenerateRuntimeSetProperty(masm(), language_mode);
Handle<Code> code = GetCodeWithFlags(flags, "CompileStoreGeneric");
PROFILE(isolate(), CodeCreateEvent(Logger::STORE_GENERIC_TAG, *code, 0));
return code;
static Handle<Code> ComputeKeyedLoadMonomorphic(Handle<Map> receiver_map);
static Handle<Code> ComputeKeyedStoreMonomorphic(
- Handle<Map> receiver_map, StrictMode strict_mode,
+ Handle<Map> receiver_map, LanguageMode language_mode,
KeyedAccessStoreMode store_mode);
static Handle<Code> ComputeKeyedLoadPolymorphic(MapHandleList* receiver_maps);
static Handle<Code> ComputeKeyedStorePolymorphic(
MapHandleList* receiver_maps, KeyedAccessStoreMode store_mode,
- StrictMode strict_mode);
+ LanguageMode language_mode);
// Compare nil
static Handle<Code> ComputeCompareNil(Handle<Map> receiver_map,
// TODO(verwaest): Move all uses of these helpers to the PropertyICCompiler
// and make the helpers private.
static void GenerateRuntimeSetProperty(MacroAssembler* masm,
- StrictMode strict_mode);
+ LanguageMode language_mode);
private:
Code* old_target = GetTargetAtAddress(address, constant_pool);
#ifdef DEBUG
// STORE_IC and KEYED_STORE_IC use Code::extra_ic_state() to mark
- // ICs as strict mode. The strict-ness of the IC must be preserved.
+ // ICs as language mode. The language mode of the IC must be preserved.
if (old_target->kind() == Code::STORE_IC ||
old_target->kind() == Code::KEYED_STORE_IC) {
- DCHECK(StoreIC::GetStrictMode(old_target->extra_ic_state()) ==
- StoreIC::GetStrictMode(target->extra_ic_state()));
+ DCHECK(StoreIC::GetLanguageMode(old_target->extra_ic_state()) ==
+ StoreIC::GetLanguageMode(target->extra_ic_state()));
}
#endif
Assembler::set_target_address_at(address, constant_pool,
void StoreIC::set_target(Code* code) {
- // Strict mode must be preserved across IC patching.
- DCHECK(GetStrictMode(code->extra_ic_state()) ==
- GetStrictMode(target()->extra_ic_state()));
+ // Language mode must be preserved across IC patching.
+ DCHECK(GetLanguageMode(code->extra_ic_state()) ==
+ GetLanguageMode(target()->extra_ic_state()));
IC::set_target(code);
}
void KeyedStoreIC::set_target(Code* code) {
- // Strict mode must be preserved across IC patching.
- DCHECK(GetStrictMode(code->extra_ic_state()) == strict_mode());
+ // Language mode must be preserved across IC patching.
+ DCHECK(GetLanguageMode(code->extra_ic_state()) == language_mode());
IC::set_target(code);
}
if (IsCleared(target)) return;
SetTargetAtAddress(
address, *pre_monomorphic_stub(
- isolate, StoreIC::GetStrictMode(target->extra_ic_state())),
+ isolate, StoreIC::GetLanguageMode(target->extra_ic_state())),
constant_pool);
}
if (!holder->HasFastProperties()) break;
Handle<JSFunction> function = Handle<JSFunction>::cast(getter);
if (!receiver->IsJSObject() && !function->IsBuiltin() &&
- function->shared()->strict_mode() == SLOPPY) {
+ is_sloppy(function->shared()->language_mode())) {
// Calling sloppy non-builtins with a value as the receiver
// requires boxing.
break;
Handle<Object> result;
ASSIGN_RETURN_ON_EXCEPTION(
isolate(), result,
- Object::SetProperty(object, name, value, strict_mode()), Object);
+ Object::SetProperty(object, name, value, language_mode()), Object);
return result;
}
Handle<Object> result;
ASSIGN_RETURN_ON_EXCEPTION(
isolate(), result,
- JSObject::SetElement(receiver, index, value, NONE, strict_mode()),
+ JSObject::SetElement(receiver, index, value, NONE, language_mode()),
Object);
return value;
}
Handle<Object> result;
ASSIGN_RETURN_ON_EXCEPTION(
isolate(), result,
- Object::SetProperty(object, name, value, strict_mode(), store_mode),
+ Object::SetProperty(object, name, value, language_mode(), store_mode),
Object);
return result;
}
Handle<Object> result;
ASSIGN_RETURN_ON_EXCEPTION(
isolate(), result,
- Object::SetProperty(&it, value, strict_mode(), store_mode), Object);
+ Object::SetProperty(&it, value, language_mode(), store_mode), Object);
return result;
}
Handle<Code> StoreIC::initialize_stub(Isolate* isolate,
- StrictMode strict_mode) {
- ExtraICState extra_state = ComputeExtraICState(strict_mode);
+ LanguageMode language_mode) {
+ ExtraICState extra_state = ComputeExtraICState(language_mode);
Handle<Code> ic =
PropertyICCompiler::ComputeStore(isolate, UNINITIALIZED, extra_state);
return ic;
extra_ic_state());
} else {
DCHECK(kind() == Code::KEYED_STORE_IC);
- if (strict_mode() == STRICT) {
+ if (is_strict(language_mode())) {
return isolate()->builtins()->KeyedStoreIC_Megamorphic_Strict();
} else {
return isolate()->builtins()->KeyedStoreIC_Megamorphic();
Handle<Code> StoreIC::pre_monomorphic_stub(Isolate* isolate,
- StrictMode strict_mode) {
- ExtraICState state = ComputeExtraICState(strict_mode);
+ LanguageMode language_mode) {
+ ExtraICState state = ComputeExtraICState(language_mode);
return PropertyICCompiler::ComputeStore(isolate, PREMONOMORPHIC, state);
}
ComputeTransitionedMap(receiver_map, store_mode);
store_mode = GetNonTransitioningStoreMode(store_mode);
return PropertyICCompiler::ComputeKeyedStoreMonomorphic(
- monomorphic_map, strict_mode(), store_mode);
+ monomorphic_map, language_mode(), store_mode);
}
// There are several special cases where an IC that is MONOMORPHIC can still
// stay MONOMORPHIC and use the map for the most generic ElementsKind.
store_mode = GetNonTransitioningStoreMode(store_mode);
return PropertyICCompiler::ComputeKeyedStoreMonomorphic(
- transitioned_receiver_map, strict_mode(), store_mode);
+ transitioned_receiver_map, language_mode(), store_mode);
} else if (*previous_receiver_map == receiver->map() &&
old_store_mode == STANDARD_STORE &&
(store_mode == STORE_AND_GROW_NO_TRANSITION ||
// grow at the end of the array, handle OOB accesses or copy COW arrays
// and still stay MONOMORPHIC.
return PropertyICCompiler::ComputeKeyedStoreMonomorphic(
- receiver_map, strict_mode(), store_mode);
+ receiver_map, language_mode(), store_mode);
}
}
}
return PropertyICCompiler::ComputeKeyedStorePolymorphic(
- &target_receiver_maps, store_mode, strict_mode());
+ &target_receiver_maps, store_mode, language_mode());
}
Handle<Object> result;
ASSIGN_RETURN_ON_EXCEPTION(
isolate(), result, Runtime::SetObjectProperty(isolate(), object, key,
- value, strict_mode()),
+ value, language_mode()),
Object);
return result;
}
bool key_is_smi_like = !Object::ToSmi(isolate(), key).is_null();
if (receiver->elements()->map() ==
isolate()->heap()->sloppy_arguments_elements_map()) {
- if (strict_mode() == SLOPPY) {
+ if (is_sloppy(language_mode())) {
stub = sloppy_arguments_stub();
} else {
TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "arguments receiver");
ASSIGN_RETURN_ON_EXCEPTION(
isolate(), store_handle,
Runtime::SetObjectProperty(isolate(), object, key, value,
- strict_mode()),
+ language_mode()),
Object);
}
Handle<Object> object = args.at<Object>(0);
Handle<Object> key = args.at<Object>(1);
Handle<Object> value = args.at<Object>(2);
- StrictMode strict_mode = ic.strict_mode();
+ LanguageMode language_mode = ic.language_mode();
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
- Runtime::SetObjectProperty(isolate, object, key, value, strict_mode));
+ Runtime::SetObjectProperty(isolate, object, key, value, language_mode));
return *result;
}
Handle<Object> object = args.at<Object>(0);
Handle<Object> key = args.at<Object>(1);
Handle<Object> value = args.at<Object>(2);
- StrictMode strict_mode = ic.strict_mode();
+ LanguageMode language_mode = ic.language_mode();
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
- Runtime::SetObjectProperty(isolate, object, key, value, strict_mode));
+ Runtime::SetObjectProperty(isolate, object, key, value, language_mode));
return *result;
}
Handle<Map> map = args.at<Map>(1);
Handle<Object> key = args.at<Object>(2);
Handle<Object> object = args.at<Object>(3);
- StrictMode strict_mode = ic.strict_mode();
+ LanguageMode language_mode = ic.language_mode();
if (object->IsJSObject()) {
JSObject::TransitionElementsKind(Handle<JSObject>::cast(object),
map->elements_kind());
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
- Runtime::SetObjectProperty(isolate, object, key, value, strict_mode));
+ Runtime::SetObjectProperty(isolate, object, key, value, language_mode));
return *result;
}
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
- JSObject::SetProperty(receiver, name, value, ic.strict_mode()));
+ JSObject::SetProperty(receiver, name, value, ic.language_mode()));
return *result;
}
class StoreIC : public IC {
public:
- class StrictModeState : public BitField<StrictMode, 1, 1> {};
- static ExtraICState ComputeExtraICState(StrictMode flag) {
- return StrictModeState::encode(flag);
+ STATIC_ASSERT(i::LANGUAGE_END == 2);
+ class LanguageModeState : public BitField<LanguageMode, 1, 1> {};
+ static ExtraICState ComputeExtraICState(LanguageMode flag) {
+ return LanguageModeState::encode(flag);
}
- static StrictMode GetStrictMode(ExtraICState state) {
- return StrictModeState::decode(state);
+ static LanguageMode GetLanguageMode(ExtraICState state) {
+ return LanguageModeState::decode(state);
}
// For convenience, a statically declared encoding of strict mode extra
// IC state.
- static const ExtraICState kStrictModeState = 1 << StrictModeState::kShift;
+ static const ExtraICState kStrictModeState = STRICT
+ << LanguageModeState::kShift;
StoreIC(FrameDepth depth, Isolate* isolate) : IC(depth, isolate) {
DCHECK(IsStoreStub());
}
- StrictMode strict_mode() const {
- return StrictModeState::decode(extra_ic_state());
+ LanguageMode language_mode() const {
+ return LanguageModeState::decode(extra_ic_state());
}
// Code generators for stub routines. Only called once at startup.
static void GenerateMegamorphic(MacroAssembler* masm);
static void GenerateNormal(MacroAssembler* masm);
static void GenerateRuntimeSetProperty(MacroAssembler* masm,
- StrictMode strict_mode);
+ LanguageMode language_mode);
- static Handle<Code> initialize_stub(Isolate* isolate, StrictMode strict_mode);
+ static Handle<Code> initialize_stub(Isolate* isolate,
+ LanguageMode language_mode);
MUST_USE_RESULT MaybeHandle<Object> Store(
Handle<Object> object, Handle<Name> name, Handle<Object> value,
Handle<Code> slow_stub() const;
virtual Handle<Code> pre_monomorphic_stub() const {
- return pre_monomorphic_stub(isolate(), strict_mode());
+ return pre_monomorphic_stub(isolate(), language_mode());
}
static Handle<Code> pre_monomorphic_stub(Isolate* isolate,
- StrictMode strict_mode);
+ LanguageMode language_mode);
// Update the inline cache and the global stub cache based on the
// lookup result.
class IcCheckTypeField : public BitField<IcCheckType, 6, 1> {};
- static ExtraICState ComputeExtraICState(StrictMode flag,
+ static ExtraICState ComputeExtraICState(LanguageMode flag,
KeyedAccessStoreMode mode) {
- return StrictModeState::encode(flag) |
+ return LanguageModeState::encode(flag) |
ExtraICStateKeyedAccessStoreMode::encode(mode) |
IcCheckTypeField::encode(ELEMENT);
}
}
static void GenerateMiss(MacroAssembler* masm);
static void GenerateSlow(MacroAssembler* masm);
- static void GenerateMegamorphic(MacroAssembler* masm, StrictMode strict_mode);
+ static void GenerateMegamorphic(MacroAssembler* masm,
+ LanguageMode language_mode);
static void GenerateSloppyArguments(MacroAssembler* masm);
protected:
virtual Handle<Code> pre_monomorphic_stub() const {
- return pre_monomorphic_stub(isolate(), strict_mode());
+ return pre_monomorphic_stub(isolate(), language_mode());
}
static Handle<Code> pre_monomorphic_stub(Isolate* isolate,
- StrictMode strict_mode) {
- if (strict_mode == STRICT) {
+ LanguageMode language_mode) {
+ if (is_strict(language_mode)) {
return isolate->builtins()->KeyedStoreIC_PreMonomorphic_Strict();
} else {
return isolate->builtins()->KeyedStoreIC_PreMonomorphic();
#define __ ACCESS_MASM(masm)
-void PropertyICCompiler::GenerateRuntimeSetProperty(MacroAssembler* masm,
- StrictMode strict_mode) {
+void PropertyICCompiler::GenerateRuntimeSetProperty(
+ MacroAssembler* masm, LanguageMode language_mode) {
// Return address is on the stack.
DCHECK(!rbx.is(StoreDescriptor::ReceiverRegister()) &&
!rbx.is(StoreDescriptor::NameRegister()) &&
__ Push(StoreDescriptor::ReceiverRegister());
__ Push(StoreDescriptor::NameRegister());
__ Push(StoreDescriptor::ValueRegister());
- __ Push(Smi::FromInt(strict_mode));
+ __ Push(Smi::FromInt(language_mode));
__ PushReturnAddressFrom(rbx);
// Do tail-call to runtime routine.
void KeyedStoreIC::GenerateMegamorphic(MacroAssembler* masm,
- StrictMode strict_mode) {
+ LanguageMode language_mode) {
// Return address is on the stack.
Label slow, slow_with_tagged_index, fast_object, fast_object_grow;
Label fast_double, fast_double_grow;
__ bind(&slow);
__ Integer32ToSmi(key, key);
__ bind(&slow_with_tagged_index);
- PropertyICCompiler::GenerateRuntimeSetProperty(masm, strict_mode);
+ PropertyICCompiler::GenerateRuntimeSetProperty(masm, language_mode);
// Never returns to here.
__ bind(&maybe_name_key);
// mode function. The number of sloppy frames is stored as
// first element in the result array.
if (!encountered_strict_function) {
- if (fun->shared()->strict_mode() == STRICT) {
+ if (is_strict(fun->shared()->language_mode())) {
encountered_strict_function = true;
} else {
sloppy_frames++;
Handle<JSReceiver> receiver,
uint32_t index,
Handle<Object> value,
- StrictMode strict_mode) {
+ LanguageMode language_mode) {
Isolate* isolate = proxy->GetIsolate();
Handle<String> name = isolate->factory()->Uint32ToString(index);
- return SetPropertyWithHandler(proxy, receiver, name, value, strict_mode);
+ return SetPropertyWithHandler(proxy, receiver, name, value, language_mode);
}
}
-StrictMode SharedFunctionInfo::strict_mode() {
+LanguageMode SharedFunctionInfo::language_mode() {
+ STATIC_ASSERT(LANGUAGE_END == 2);
return BooleanBit::get(compiler_hints(), kStrictModeFunction)
? STRICT : SLOPPY;
}
-void SharedFunctionInfo::set_strict_mode(StrictMode strict_mode) {
- // We only allow mode transitions from sloppy to strict.
- DCHECK(this->strict_mode() == SLOPPY || this->strict_mode() == strict_mode);
+void SharedFunctionInfo::set_language_mode(LanguageMode language_mode) {
+ STATIC_ASSERT(LANGUAGE_END == 2);
+ // We only allow language mode transitions that set the same language mode
+ // again or go up in the chain:
+ DCHECK(is_sloppy(this->language_mode()) || is_strict(language_mode));
int hints = compiler_hints();
- hints = BooleanBit::set(hints, kStrictModeFunction, strict_mode == STRICT);
+ hints = BooleanBit::set(hints, kStrictModeFunction, is_strict(language_mode));
set_compiler_hints(hints);
}
MaybeHandle<Object> Object::SetPropertyWithAccessor(
Handle<Object> receiver, Handle<Name> name, Handle<Object> value,
- Handle<JSObject> holder, Handle<Object> structure, StrictMode strict_mode) {
+ Handle<JSObject> holder, Handle<Object> structure,
+ LanguageMode language_mode) {
Isolate* isolate = name->GetIsolate();
// We should never get here to initialize a const with the hole
return SetPropertyWithDefinedSetter(
receiver, Handle<JSReceiver>::cast(setter), value);
} else {
- if (strict_mode == SLOPPY) return value;
+ if (is_sloppy(language_mode)) return value;
Handle<Object> args[2] = { name, holder };
THROW_NEW_ERROR(
isolate, NewTypeError("no_setter_in_callback", HandleVector(args, 2)),
MaybeHandle<Object> JSObject::SetPropertyWithFailedAccessCheck(
- LookupIterator* it, Handle<Object> value, StrictMode strict_mode) {
+ LookupIterator* it, Handle<Object> value, LanguageMode language_mode) {
Handle<JSObject> checked = it->GetHolder<JSObject>();
if (FindAllCanWriteHolder(it)) {
return SetPropertyWithAccessor(it->GetReceiver(), it->name(), value,
it->GetHolder<JSObject>(),
- it->GetAccessors(), strict_mode);
+ it->GetAccessors(), language_mode);
}
it->isolate()->ReportFailedAccessCheck(checked, v8::ACCESS_SET);
MaybeHandle<Object> Object::SetElementWithReceiver(
Isolate* isolate, Handle<Object> object, Handle<Object> receiver,
- uint32_t index, Handle<Object> value, StrictMode strict_mode) {
+ uint32_t index, Handle<Object> value, LanguageMode language_mode) {
// Iterate up the prototype chain until an element is found or the null
// prototype is encountered.
bool done = false;
if (!from_interceptor.has_value) return MaybeHandle<Object>();
if ((from_interceptor.value & READ_ONLY) != 0) {
return WriteToReadOnlyElement(isolate, receiver, index, value,
- strict_mode);
+ language_mode);
}
done = from_interceptor.value != ABSENT;
}
accessor->GetAttributes(receiver, js_object, index);
if ((attrs & READ_ONLY) != 0) {
return WriteToReadOnlyElement(isolate, receiver, index, value,
- strict_mode);
+ language_mode);
}
Handle<AccessorPair> accessor_pair;
if (accessor->GetAccessorPair(receiver, js_object, index)
.ToHandle(&accessor_pair)) {
- return JSObject::SetElementWithCallback(receiver, accessor_pair, index,
- value, js_object, strict_mode);
+ return JSObject::SetElementWithCallback(
+ receiver, accessor_pair, index, value, js_object, language_mode);
} else {
done = attrs != ABSENT;
}
}
if (!receiver->IsJSObject()) {
- return WriteToReadOnlyElement(isolate, receiver, index, value, strict_mode);
+ return WriteToReadOnlyElement(isolate, receiver, index, value,
+ language_mode);
}
Handle<JSObject> target = Handle<JSObject>::cast(receiver);
ElementsAccessor* accessor = target->GetElementsAccessor();
PropertyAttributes attrs = accessor->GetAttributes(receiver, target, index);
if ((attrs & READ_ONLY) != 0) {
- return WriteToReadOnlyElement(isolate, receiver, index, value, strict_mode);
+ return WriteToReadOnlyElement(isolate, receiver, index, value,
+ language_mode);
}
PropertyAttributes new_attrs = attrs != ABSENT ? attrs : NONE;
- return JSObject::SetElement(target, index, value, new_attrs, strict_mode,
+ return JSObject::SetElement(target, index, value, new_attrs, language_mode,
false);
}
MaybeHandle<Object> Object::SetProperty(Handle<Object> object,
Handle<Name> name, Handle<Object> value,
- StrictMode strict_mode,
+ LanguageMode language_mode,
StoreFromKeyed store_mode) {
LookupIterator it(object, name);
- return SetProperty(&it, value, strict_mode, store_mode);
+ return SetProperty(&it, value, language_mode, store_mode);
}
MaybeHandle<Object> Object::SetProperty(LookupIterator* it,
Handle<Object> value,
- StrictMode strict_mode,
+ LanguageMode language_mode,
StoreFromKeyed store_mode,
StorePropertyMode data_store_mode) {
// Make sure that the top context does not change when doing callbacks or
// until we find the property.
if (it->HasAccess(v8::ACCESS_SET)) break;
return JSObject::SetPropertyWithFailedAccessCheck(it, value,
- strict_mode);
+ language_mode);
case LookupIterator::JSPROXY:
if (it->HolderIsReceiverOrHiddenPrototype()) {
return JSProxy::SetPropertyWithHandler(it->GetHolder<JSProxy>(),
it->GetReceiver(), it->name(),
- value, strict_mode);
+ value, language_mode);
} else {
// TODO(verwaest): Use the MaybeHandle to indicate result.
bool has_result = false;
MaybeHandle<Object> maybe_result =
JSProxy::SetPropertyViaPrototypesWithHandler(
it->GetHolder<JSProxy>(), it->GetReceiver(), it->name(),
- value, strict_mode, &has_result);
+ value, language_mode, &has_result);
if (has_result) return maybe_result;
done = true;
}
if (!maybe_attributes.has_value) return MaybeHandle<Object>();
done = maybe_attributes.value != ABSENT;
if (done && (maybe_attributes.value & READ_ONLY) != 0) {
- return WriteToReadOnlyProperty(it, value, strict_mode);
+ return WriteToReadOnlyProperty(it, value, language_mode);
}
}
break;
case LookupIterator::ACCESSOR:
if (it->property_details().IsReadOnly()) {
- return WriteToReadOnlyProperty(it, value, strict_mode);
+ return WriteToReadOnlyProperty(it, value, language_mode);
}
return SetPropertyWithAccessor(it->GetReceiver(), it->name(), value,
it->GetHolder<JSObject>(),
- it->GetAccessors(), strict_mode);
+ it->GetAccessors(), language_mode);
case LookupIterator::DATA:
if (it->property_details().IsReadOnly()) {
- return WriteToReadOnlyProperty(it, value, strict_mode);
+ return WriteToReadOnlyProperty(it, value, language_mode);
}
if (it->HolderIsReceiverOrHiddenPrototype()) {
return SetDataProperty(it, value);
// If the receiver is the JSGlobalObject, the store was contextual. In case
// the property did not exist yet on the global object itself, we have to
// throw a reference error in strict mode.
- if (it->GetReceiver()->IsJSGlobalObject() && strict_mode == STRICT) {
+ if (it->GetReceiver()->IsJSGlobalObject() && is_strict(language_mode)) {
Handle<Object> args[1] = {it->name()};
THROW_NEW_ERROR(it->isolate(),
NewReferenceError("not_defined", HandleVector(args, 1)),
LookupIterator own_lookup(it->GetReceiver(), it->name(),
LookupIterator::OWN);
- return JSObject::SetProperty(&own_lookup, value, strict_mode, store_mode,
+ return JSObject::SetProperty(&own_lookup, value, language_mode, store_mode,
NORMAL_PROPERTY);
}
- return AddDataProperty(it, value, NONE, strict_mode, store_mode);
+ return AddDataProperty(it, value, NONE, language_mode, store_mode);
}
-MaybeHandle<Object> Object::WriteToReadOnlyProperty(LookupIterator* it,
- Handle<Object> value,
- StrictMode strict_mode) {
- if (strict_mode != STRICT) return value;
+MaybeHandle<Object> Object::WriteToReadOnlyProperty(
+ LookupIterator* it, Handle<Object> value, LanguageMode language_mode) {
+ if (is_sloppy(language_mode)) return value;
Handle<Object> args[] = {it->name(), it->GetReceiver()};
THROW_NEW_ERROR(it->isolate(),
Handle<Object> receiver,
uint32_t index,
Handle<Object> value,
- StrictMode strict_mode) {
- if (strict_mode != STRICT) return value;
+ LanguageMode language_mode) {
+ if (is_sloppy(language_mode)) return value;
Handle<Object> args[] = {isolate->factory()->NewNumberFromUint(index),
receiver};
MaybeHandle<Object> Object::AddDataProperty(LookupIterator* it,
Handle<Object> value,
PropertyAttributes attributes,
- StrictMode strict_mode,
+ LanguageMode language_mode,
StoreFromKeyed store_mode) {
DCHECK(!it->GetReceiver()->IsJSProxy());
if (!it->GetReceiver()->IsJSObject()) {
// TODO(verwaest): Throw a TypeError with a more specific message.
- return WriteToReadOnlyProperty(it, value, strict_mode);
+ return WriteToReadOnlyProperty(it, value, language_mode);
}
Handle<JSObject> receiver = it->GetStoreTarget();
// |value| under it->name() with |attributes|.
it->PrepareTransitionToDataProperty(value, attributes, store_mode);
if (it->state() != LookupIterator::TRANSITION) {
- if (strict_mode == SLOPPY) return value;
+ if (is_sloppy(language_mode)) return value;
Handle<Object> args[1] = {it->name()};
THROW_NEW_ERROR(it->isolate(),
MaybeHandle<Object> JSObject::SetElementWithCallbackSetterInPrototypes(
- Handle<JSObject> object,
- uint32_t index,
- Handle<Object> value,
- bool* found,
- StrictMode strict_mode) {
+ Handle<JSObject> object, uint32_t index, Handle<Object> value, bool* found,
+ LanguageMode language_mode) {
Isolate* isolate = object->GetIsolate();
for (PrototypeIterator iter(isolate, object); !iter.IsAtEnd();
iter.Advance()) {
return JSProxy::SetPropertyViaPrototypesWithHandler(
Handle<JSProxy>::cast(PrototypeIterator::GetCurrent(iter)), object,
isolate->factory()->Uint32ToString(index), // name
- value, strict_mode, found);
+ value, language_mode, found);
}
Handle<JSObject> js_proto =
Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter));
*found = true;
Handle<Object> structure(dictionary->ValueAt(entry), isolate);
return SetElementWithCallback(object, structure, index, value, js_proto,
- strict_mode);
+ language_mode);
}
}
}
}
-MaybeHandle<Object> JSProxy::SetPropertyWithHandler(Handle<JSProxy> proxy,
- Handle<Object> receiver,
- Handle<Name> name,
- Handle<Object> value,
- StrictMode strict_mode) {
+MaybeHandle<Object> JSProxy::SetPropertyWithHandler(
+ Handle<JSProxy> proxy, Handle<Object> receiver, Handle<Name> name,
+ Handle<Object> value, LanguageMode language_mode) {
Isolate* isolate = proxy->GetIsolate();
// TODO(rossberg): adjust once there is a story for symbols vs proxies.
MaybeHandle<Object> JSProxy::SetPropertyViaPrototypesWithHandler(
Handle<JSProxy> proxy, Handle<Object> receiver, Handle<Name> name,
- Handle<Object> value, StrictMode strict_mode, bool* done) {
+ Handle<Object> value, LanguageMode language_mode, bool* done) {
Isolate* isolate = proxy->GetIsolate();
Handle<Object> handler(proxy->handler(), isolate); // Trap might morph proxy.
DCHECK(writable->IsBoolean());
*done = writable->IsFalse();
if (!*done) return isolate->factory()->the_hole_value();
- if (strict_mode == SLOPPY) return value;
+ if (is_sloppy(language_mode)) return value;
Handle<Object> args[] = { name, receiver };
THROW_NEW_ERROR(isolate, NewTypeError("strict_read_only_property",
HandleVector(args, arraysize(args))),
receiver, Handle<JSReceiver>::cast(setter), value);
}
- if (strict_mode == SLOPPY) return value;
+ if (is_sloppy(language_mode)) return value;
Handle<Object> args2[] = { name, proxy };
THROW_NEW_ERROR(isolate, NewTypeError("no_setter_in_callback",
HandleVector(args2, arraysize(args2))),
}
-MaybeHandle<Object> JSProxy::DeletePropertyWithHandler(Handle<JSProxy> proxy,
- Handle<Name> name,
- StrictMode strict_mode) {
+MaybeHandle<Object> JSProxy::DeletePropertyWithHandler(
+ Handle<JSProxy> proxy, Handle<Name> name, LanguageMode language_mode) {
Isolate* isolate = proxy->GetIsolate();
// TODO(rossberg): adjust once there is a story for symbols vs proxies.
Object);
bool result_bool = result->BooleanValue();
- if (strict_mode == STRICT && !result_bool) {
+ if (is_strict(language_mode) && !result_bool) {
Handle<Object> handler(proxy->handler(), isolate);
Handle<String> trap_name = isolate->factory()->InternalizeOneByteString(
STATIC_CHAR_VECTOR("delete"));
}
-MaybeHandle<Object> JSProxy::DeleteElementWithHandler(Handle<JSProxy> proxy,
- uint32_t index,
- StrictMode strict_mode) {
+MaybeHandle<Object> JSProxy::DeleteElementWithHandler(
+ Handle<JSProxy> proxy, uint32_t index, LanguageMode language_mode) {
Isolate* isolate = proxy->GetIsolate();
Handle<String> name = isolate->factory()->Uint32ToString(index);
- return JSProxy::DeletePropertyWithHandler(proxy, name, strict_mode);
+ return JSProxy::DeletePropertyWithHandler(proxy, name, language_mode);
}
MaybeHandle<Object> JSObject::DeleteElement(Handle<JSObject> object,
uint32_t index,
- StrictMode strict_mode) {
+ LanguageMode language_mode) {
Isolate* isolate = object->GetIsolate();
Factory* factory = isolate->factory();
}
if (object->IsStringObjectWithCharacterAt(index)) {
- if (strict_mode == STRICT) {
+ if (is_strict(language_mode)) {
// Deleting a non-configurable property in strict mode.
Handle<Object> name = factory->NewNumberFromUint(index);
Handle<Object> args[2] = { name, object };
DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject());
return DeleteElement(
Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), index,
- strict_mode);
+ language_mode);
}
Handle<Object> old_value;
maybe_result = DeleteElementWithInterceptor(object, index);
} else {
maybe_result =
- object->GetElementsAccessor()->Delete(object, index, strict_mode);
+ object->GetElementsAccessor()->Delete(object, index, language_mode);
}
Handle<Object> result;
ASSIGN_RETURN_ON_EXCEPTION(isolate, result, maybe_result, Object);
MaybeHandle<Object> JSObject::DeleteProperty(Handle<JSObject> object,
Handle<Name> name,
- StrictMode strict_mode) {
+ LanguageMode language_mode) {
// ECMA-262, 3rd, 8.6.2.5
DCHECK(name->IsName());
uint32_t index = 0;
if (name->AsArrayIndex(&index)) {
- return DeleteElement(object, index, strict_mode);
+ return DeleteElement(object, index, language_mode);
}
LookupIterator it(object, name, LookupIterator::HIDDEN);
case LookupIterator::ACCESSOR: {
if (!it.IsConfigurable()) {
// Fail if the property is not configurable.
- if (strict_mode == STRICT) {
+ if (is_strict(language_mode)) {
Handle<Object> args[2] = {name, object};
THROW_NEW_ERROR(it.isolate(),
NewTypeError("strict_delete_property",
MaybeHandle<Object> JSReceiver::DeleteElement(Handle<JSReceiver> object,
uint32_t index,
- StrictMode strict_mode) {
+ LanguageMode language_mode) {
if (object->IsJSProxy()) {
return JSProxy::DeleteElementWithHandler(Handle<JSProxy>::cast(object),
- index, strict_mode);
+ index, language_mode);
}
return JSObject::DeleteElement(Handle<JSObject>::cast(object), index,
- strict_mode);
+ language_mode);
}
MaybeHandle<Object> JSReceiver::DeleteProperty(Handle<JSReceiver> object,
Handle<Name> name,
- StrictMode strict_mode) {
+ LanguageMode language_mode) {
if (object->IsJSProxy()) {
return JSProxy::DeletePropertyWithHandler(Handle<JSProxy>::cast(object),
- name, strict_mode);
+ name, language_mode);
}
return JSObject::DeleteProperty(Handle<JSObject>::cast(object), name,
- strict_mode);
+ language_mode);
}
bool JSFunction::RemovePrototype() {
Context* native_context = context()->native_context();
- Map* no_prototype_map = shared()->strict_mode() == SLOPPY
- ? native_context->sloppy_function_without_prototype_map()
- : native_context->strict_function_without_prototype_map();
+ Map* no_prototype_map =
+ is_strict(shared()->language_mode())
+ ? native_context->strict_function_without_prototype_map()
+ : native_context->sloppy_function_without_prototype_map();
if (map() == no_prototype_map) return true;
#ifdef DEBUG
- if (map() != (shared()->strict_mode() == SLOPPY
- ? native_context->sloppy_function_map()
- : native_context->strict_function_map())) {
+ if (map() != (is_strict(shared()->language_mode())
+ ? native_context->strict_function_map()
+ : native_context->sloppy_function_map())) {
return false;
}
#endif
void Code::PrintExtraICState(std::ostream& os, // NOLINT
Kind kind, ExtraICState extra) {
os << "extra_ic_state = ";
- if ((kind == STORE_IC || kind == KEYED_STORE_IC) && (extra == STRICT)) {
+ if ((kind == STORE_IC || kind == KEYED_STORE_IC) &&
+ is_strict(static_cast<LanguageMode>(extra))) {
os << "STRICT\n";
} else {
os << extra << "\n";
MaybeHandle<Object> JSObject::SetElementWithInterceptor(
- Handle<JSObject> object,
- uint32_t index,
- Handle<Object> value,
- PropertyAttributes attributes,
- StrictMode strict_mode,
- bool check_prototype,
- SetPropertyMode set_mode) {
+ Handle<JSObject> object, uint32_t index, Handle<Object> value,
+ PropertyAttributes attributes, LanguageMode language_mode,
+ bool check_prototype, SetPropertyMode set_mode) {
Isolate* isolate = object->GetIsolate();
// Make sure that the top context does not change when doing
}
return SetElementWithoutInterceptor(object, index, value, attributes,
- strict_mode,
- check_prototype,
- set_mode);
+ language_mode, check_prototype, set_mode);
}
MaybeHandle<Object> JSObject::SetElementWithCallback(
Handle<Object> object, Handle<Object> structure, uint32_t index,
- Handle<Object> value, Handle<JSObject> holder, StrictMode strict_mode) {
+ Handle<Object> value, Handle<JSObject> holder, LanguageMode language_mode) {
Isolate* isolate = holder->GetIsolate();
// We should never get here to initialize a const with the hole
return SetPropertyWithDefinedSetter(
object, Handle<JSReceiver>::cast(setter), value);
} else {
- if (strict_mode == SLOPPY) return value;
+ if (is_sloppy(language_mode)) return value;
Handle<Object> key(isolate->factory()->NewNumberFromUint(index));
Handle<Object> args[2] = { key, holder };
THROW_NEW_ERROR(
MaybeHandle<Object> JSObject::SetFastElement(Handle<JSObject> object,
uint32_t index,
Handle<Object> value,
- StrictMode strict_mode,
+ LanguageMode language_mode,
bool check_prototype) {
DCHECK(object->HasFastSmiOrObjectElements() ||
object->HasFastArgumentsElements());
(index >= capacity || backing_store->get(index)->IsTheHole())) {
bool found;
MaybeHandle<Object> result = SetElementWithCallbackSetterInPrototypes(
- object, index, value, &found, strict_mode);
+ object, index, value, &found, language_mode);
if (found) return result;
}
}
if (convert_to_slow) {
NormalizeElements(object);
- return SetDictionaryElement(object, index, value, NONE, strict_mode,
+ return SetDictionaryElement(object, index, value, NONE, language_mode,
check_prototype);
}
}
MaybeHandle<Object> JSObject::SetDictionaryElement(
- Handle<JSObject> object,
- uint32_t index,
- Handle<Object> value,
- PropertyAttributes attributes,
- StrictMode strict_mode,
- bool check_prototype,
- SetPropertyMode set_mode) {
+ Handle<JSObject> object, uint32_t index, Handle<Object> value,
+ PropertyAttributes attributes, LanguageMode language_mode,
+ bool check_prototype, SetPropertyMode set_mode) {
DCHECK(object->HasDictionaryElements() ||
object->HasDictionaryArgumentsElements());
Isolate* isolate = object->GetIsolate();
PropertyDetails details = dictionary->DetailsAt(entry);
if (details.type() == ACCESSOR_CONSTANT && set_mode == SET_PROPERTY) {
return SetElementWithCallback(object, element, index, value, object,
- strict_mode);
+ language_mode);
} else {
dictionary->UpdateMaxNumberKey(index);
// If a value has not been initialized we allow writing to it even if it
details = PropertyDetails(attributes, DATA, details.dictionary_index());
dictionary->DetailsAtPut(entry, details);
} else if (details.IsReadOnly() && !element->IsTheHole()) {
- if (strict_mode == SLOPPY) {
+ if (is_sloppy(language_mode)) {
return isolate->factory()->undefined_value();
} else {
Handle<Object> number = isolate->factory()->NewNumberFromUint(index);
if (check_prototype) {
bool found;
MaybeHandle<Object> result = SetElementWithCallbackSetterInPrototypes(
- object, index, value, &found, strict_mode);
+ object, index, value, &found, language_mode);
if (found) return result;
}
// When we set the is_extensible flag to false we always force the
// element into dictionary mode (and force them to stay there).
if (!object->map()->is_extensible()) {
- if (strict_mode == SLOPPY) {
+ if (is_sloppy(language_mode)) {
return isolate->factory()->undefined_value();
} else {
Handle<Object> number = isolate->factory()->NewNumberFromUint(index);
return value;
}
-MaybeHandle<Object> JSObject::SetFastDoubleElement(
- Handle<JSObject> object,
- uint32_t index,
- Handle<Object> value,
- StrictMode strict_mode,
- bool check_prototype) {
+MaybeHandle<Object> JSObject::SetFastDoubleElement(Handle<JSObject> object,
+ uint32_t index,
+ Handle<Object> value,
+ LanguageMode language_mode,
+ bool check_prototype) {
DCHECK(object->HasFastDoubleElements());
Handle<FixedArrayBase> base_elms(FixedArrayBase::cast(object->elements()));
Handle<FixedDoubleArray>::cast(base_elms)->is_the_hole(index))) {
bool found;
MaybeHandle<Object> result = SetElementWithCallbackSetterInPrototypes(
- object, index, value, &found, strict_mode);
+ object, index, value, &found, language_mode);
if (found) return result;
}
Handle<Object> result;
ASSIGN_RETURN_ON_EXCEPTION(
object->GetIsolate(), result,
- SetFastElement(object, index, value, strict_mode, check_prototype),
+ SetFastElement(object, index, value, language_mode, check_prototype),
Object);
JSObject::ValidateElements(object);
return result;
NormalizeElements(object);
DCHECK(object->HasDictionaryElements());
- return SetElement(object, index, value, NONE, strict_mode, check_prototype);
+ return SetElement(object, index, value, NONE, language_mode, check_prototype);
}
MaybeHandle<Object> JSReceiver::SetElement(Handle<JSReceiver> object,
- uint32_t index,
- Handle<Object> value,
+ uint32_t index, Handle<Object> value,
PropertyAttributes attributes,
- StrictMode strict_mode) {
+ LanguageMode language_mode) {
if (object->IsJSProxy()) {
- return JSProxy::SetElementWithHandler(
- Handle<JSProxy>::cast(object), object, index, value, strict_mode);
+ return JSProxy::SetElementWithHandler(Handle<JSProxy>::cast(object), object,
+ index, value, language_mode);
}
- return JSObject::SetElement(
- Handle<JSObject>::cast(object), index, value, attributes, strict_mode);
+ return JSObject::SetElement(Handle<JSObject>::cast(object), index, value,
+ attributes, language_mode);
}
MaybeHandle<Object> JSObject::SetOwnElement(Handle<JSObject> object,
uint32_t index,
Handle<Object> value,
- StrictMode strict_mode) {
+ LanguageMode language_mode) {
DCHECK(!object->HasExternalArrayElements());
- return JSObject::SetElement(object, index, value, NONE, strict_mode, false);
+ return JSObject::SetElement(object, index, value, NONE, language_mode, false);
}
MaybeHandle<Object> JSObject::SetElement(Handle<JSObject> object,
- uint32_t index,
- Handle<Object> value,
+ uint32_t index, Handle<Object> value,
PropertyAttributes attributes,
- StrictMode strict_mode,
+ LanguageMode language_mode,
bool check_prototype,
SetPropertyMode set_mode) {
Isolate* isolate = object->GetIsolate();
DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject());
return SetElement(
Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), index,
- value, attributes, strict_mode, check_prototype, set_mode);
+ value, attributes, language_mode, check_prototype, set_mode);
}
// Don't allow element properties to be redefined for external arrays.
if (!object->map()->is_observed()) {
return object->HasIndexedInterceptor()
- ? SetElementWithInterceptor(object, index, value, attributes,
- strict_mode, check_prototype, set_mode)
- : SetElementWithoutInterceptor(object, index, value, attributes,
- strict_mode, check_prototype, set_mode);
+ ? SetElementWithInterceptor(object, index, value, attributes,
+ language_mode, check_prototype,
+ set_mode)
+ : SetElementWithoutInterceptor(object, index, value, attributes,
+ language_mode, check_prototype,
+ set_mode);
}
Maybe<PropertyAttributes> maybe =
ASSIGN_RETURN_ON_EXCEPTION(
isolate, result,
object->HasIndexedInterceptor()
- ? SetElementWithInterceptor(
- object, index, value, attributes,
- strict_mode, check_prototype, set_mode)
- : SetElementWithoutInterceptor(
- object, index, value, attributes,
- strict_mode, check_prototype, set_mode),
+ ? SetElementWithInterceptor(object, index, value, attributes,
+ language_mode, check_prototype, set_mode)
+ : SetElementWithoutInterceptor(object, index, value, attributes,
+ language_mode, check_prototype,
+ set_mode),
Object);
Handle<String> name = isolate->factory()->Uint32ToString(index);
MaybeHandle<Object> JSObject::SetElementWithoutInterceptor(
- Handle<JSObject> object,
- uint32_t index,
- Handle<Object> value,
- PropertyAttributes attributes,
- StrictMode strict_mode,
- bool check_prototype,
- SetPropertyMode set_mode) {
+ Handle<JSObject> object, uint32_t index, Handle<Object> value,
+ PropertyAttributes attributes, LanguageMode language_mode,
+ bool check_prototype, SetPropertyMode set_mode) {
DCHECK(object->HasDictionaryElements() ||
object->HasDictionaryArgumentsElements() ||
(attributes & (DONT_DELETE | DONT_ENUM | READ_ONLY)) == 0);
}
if (object->IsJSArray() && JSArray::WouldChangeReadOnlyLength(
Handle<JSArray>::cast(object), index)) {
- if (strict_mode == SLOPPY) {
+ if (is_sloppy(language_mode)) {
return value;
} else {
return JSArray::ReadOnlyLengthError(Handle<JSArray>::cast(object));
case FAST_ELEMENTS:
case FAST_HOLEY_SMI_ELEMENTS:
case FAST_HOLEY_ELEMENTS:
- return SetFastElement(object, index, value, strict_mode, check_prototype);
+ return SetFastElement(object, index, value, language_mode,
+ check_prototype);
case FAST_DOUBLE_ELEMENTS:
case FAST_HOLEY_DOUBLE_ELEMENTS:
- return SetFastDoubleElement(object, index, value, strict_mode,
+ return SetFastDoubleElement(object, index, value, language_mode,
check_prototype);
#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
#undef TYPED_ARRAY_CASE
case DICTIONARY_ELEMENTS:
- return SetDictionaryElement(object, index, value, attributes, strict_mode,
- check_prototype,
- set_mode);
+ return SetDictionaryElement(object, index, value, attributes,
+ language_mode, check_prototype, set_mode);
case SLOPPY_ARGUMENTS_ELEMENTS: {
Handle<FixedArray> parameter_map(FixedArray::cast(object->elements()));
uint32_t length = parameter_map->length();
Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1)));
if (arguments->IsDictionary()) {
return SetDictionaryElement(object, index, value, attributes,
- strict_mode,
- check_prototype,
- set_mode);
+ language_mode, check_prototype, set_mode);
} else {
- return SetFastElement(object, index, value, strict_mode,
+ return SetFastElement(object, index, value, language_mode,
check_prototype);
}
}
// StringSharedKeys are used as keys in the eval cache.
class StringSharedKey : public HashTableKey {
public:
- StringSharedKey(Handle<String> source,
- Handle<SharedFunctionInfo> shared,
- StrictMode strict_mode,
- int scope_position)
+ StringSharedKey(Handle<String> source, Handle<SharedFunctionInfo> shared,
+ LanguageMode language_mode, int scope_position)
: source_(source),
shared_(shared),
- strict_mode_(strict_mode),
- scope_position_(scope_position) { }
+ language_mode_(language_mode),
+ scope_position_(scope_position) {}
bool IsMatch(Object* other) OVERRIDE {
DisallowHeapAllocation no_allocation;
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();
- DCHECK(strict_unchecked == SLOPPY || strict_unchecked == STRICT);
- StrictMode strict_mode = static_cast<StrictMode>(strict_unchecked);
- if (strict_mode != strict_mode_) return false;
+ int language_unchecked = Smi::cast(other_array->get(2))->value();
+ DCHECK(is_valid_language_mode(language_unchecked));
+ 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));
static uint32_t StringSharedHashHelper(String* source,
SharedFunctionInfo* shared,
- StrictMode strict_mode,
+ LanguageMode language_mode,
int scope_position) {
uint32_t hash = source->Hash();
if (shared->HasSourceCode()) {
// collection.
Script* script(Script::cast(shared->script()));
hash ^= String::cast(script->source())->Hash();
- if (strict_mode == STRICT) hash ^= 0x8000;
+ STATIC_ASSERT(LANGUAGE_END == 2);
+ if (is_strict(language_mode)) hash ^= 0x8000;
hash += scope_position;
}
return hash;
}
uint32_t Hash() OVERRIDE {
- return StringSharedHashHelper(*source_, *shared_, strict_mode_,
+ return StringSharedHashHelper(*source_, *shared_, language_mode_,
scope_position_);
}
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();
- DCHECK(strict_unchecked == SLOPPY || strict_unchecked == STRICT);
- StrictMode strict_mode = static_cast<StrictMode>(strict_unchecked);
+ int language_unchecked = Smi::cast(other_array->get(2))->value();
+ DCHECK(is_valid_language_mode(language_unchecked));
+ 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);
}
Handle<FixedArray> array = isolate->factory()->NewFixedArray(4);
array->set(0, *shared_);
array->set(1, *source_);
- array->set(2, Smi::FromInt(strict_mode_));
+ array->set(2, Smi::FromInt(language_mode_));
array->set(3, Smi::FromInt(scope_position_));
return array;
}
private:
Handle<String> source_;
Handle<SharedFunctionInfo> shared_;
- StrictMode strict_mode_;
+ LanguageMode language_mode_;
int scope_position_;
};
Handle<Object> CompilationCacheTable::LookupEval(
Handle<String> src, Handle<SharedFunctionInfo> outer_info,
- StrictMode strict_mode, int scope_position) {
+ LanguageMode language_mode, int scope_position) {
Isolate* isolate = GetIsolate();
// Cache key is the tuple (source, outer shared function info, scope position)
// to unambiguously identify the context chain the cached eval code assumes.
- StringSharedKey key(src, outer_info, strict_mode, scope_position);
+ StringSharedKey key(src, outer_info, language_mode, scope_position);
int entry = FindEntry(&key);
if (entry == kNotFound) return isolate->factory()->undefined_value();
int index = EntryToIndex(entry);
Handle<SharedFunctionInfo> outer_info, Handle<SharedFunctionInfo> value,
int scope_position) {
Isolate* isolate = cache->GetIsolate();
- StringSharedKey key(src, outer_info, value->strict_mode(), scope_position);
+ StringSharedKey key(src, outer_info, value->language_mode(), scope_position);
{
Handle<Object> k = key.AsHandle(isolate);
DisallowHeapAllocation no_allocation_scope;
// Implementation of [[Put]], ECMA-262 5th edition, section 8.12.5.
MUST_USE_RESULT static MaybeHandle<Object> SetProperty(
Handle<Object> object, Handle<Name> key, Handle<Object> value,
- StrictMode strict_mode,
+ LanguageMode language_mode,
StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED);
MUST_USE_RESULT static MaybeHandle<Object> SetProperty(
- LookupIterator* it, Handle<Object> value, StrictMode strict_mode,
+ LookupIterator* it, Handle<Object> value, LanguageMode language_mode,
StoreFromKeyed store_mode,
StorePropertyMode data_store_mode = NORMAL_PROPERTY);
MUST_USE_RESULT static MaybeHandle<Object> WriteToReadOnlyProperty(
- LookupIterator* it, Handle<Object> value, StrictMode strict_mode);
+ LookupIterator* it, Handle<Object> value, LanguageMode language_mode);
MUST_USE_RESULT static MaybeHandle<Object> WriteToReadOnlyElement(
Isolate* isolate, Handle<Object> receiver, uint32_t index,
- Handle<Object> value, StrictMode strict_mode);
+ Handle<Object> value, LanguageMode language_mode);
MUST_USE_RESULT static MaybeHandle<Object> SetDataProperty(
LookupIterator* it, Handle<Object> value);
MUST_USE_RESULT static MaybeHandle<Object> AddDataProperty(
LookupIterator* it, Handle<Object> value, PropertyAttributes attributes,
- StrictMode strict_mode, StoreFromKeyed store_mode);
+ LanguageMode language_mode, StoreFromKeyed store_mode);
MUST_USE_RESULT static inline MaybeHandle<Object> GetPropertyOrElement(
Handle<Object> object,
Handle<Name> key);
MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithAccessor(
Handle<Object> receiver, Handle<Name> name, Handle<Object> value,
Handle<JSObject> holder, Handle<Object> structure,
- StrictMode strict_mode);
+ LanguageMode language_mode);
MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithDefinedGetter(
Handle<Object> receiver,
MUST_USE_RESULT static MaybeHandle<Object> SetElementWithReceiver(
Isolate* isolate, Handle<Object> object, Handle<Object> receiver,
- uint32_t index, Handle<Object> value, StrictMode strict_mode);
+ uint32_t index, Handle<Object> value, LanguageMode language_mode);
static inline Handle<Object> GetPrototypeSkipHiddenPrototypes(
Isolate* isolate, Handle<Object> receiver);
DECLARE_CAST(JSReceiver)
MUST_USE_RESULT static MaybeHandle<Object> SetElement(
- Handle<JSReceiver> object,
- uint32_t index,
- Handle<Object> value,
- PropertyAttributes attributes,
- StrictMode strict_mode);
+ Handle<JSReceiver> object, uint32_t index, Handle<Object> value,
+ PropertyAttributes attributes, LanguageMode language_mode);
// Implementation of [[HasProperty]], ECMA-262 5th edition, section 8.12.6.
MUST_USE_RESULT static inline Maybe<bool> HasProperty(
// Implementation of [[Delete]], ECMA-262 5th edition, section 8.12.7.
MUST_USE_RESULT static MaybeHandle<Object> DeleteProperty(
Handle<JSReceiver> object, Handle<Name> name,
- StrictMode strict_mode = SLOPPY);
+ LanguageMode language_mode = SLOPPY);
MUST_USE_RESULT static MaybeHandle<Object> DeleteElement(
Handle<JSReceiver> object, uint32_t index,
- StrictMode strict_mode = SLOPPY);
+ LanguageMode language_mode = SLOPPY);
// Tests for the fast common case for property enumeration.
bool IsSimpleEnum();
Handle<JSObject> object, uint32_t index);
MUST_USE_RESULT static MaybeHandle<Object> SetFastElement(
- Handle<JSObject> object,
- uint32_t index,
- Handle<Object> value,
- StrictMode strict_mode,
- bool check_prototype);
+ Handle<JSObject> object, uint32_t index, Handle<Object> value,
+ LanguageMode language_mode, bool check_prototype);
MUST_USE_RESULT static MaybeHandle<Object> SetOwnElement(
- Handle<JSObject> object,
- uint32_t index,
- Handle<Object> value,
- StrictMode strict_mode);
+ Handle<JSObject> object, uint32_t index, Handle<Object> value,
+ LanguageMode language_mode);
// Empty handle is returned if the element cannot be set to the given value.
MUST_USE_RESULT static MaybeHandle<Object> SetElement(
- Handle<JSObject> object,
- uint32_t index,
- Handle<Object> value,
- PropertyAttributes attributes,
- StrictMode strict_mode,
- bool check_prototype = true,
- SetPropertyMode set_mode = SET_PROPERTY);
+ Handle<JSObject> object, uint32_t index, Handle<Object> value,
+ PropertyAttributes attributes, LanguageMode language_mode,
+ bool check_prototype = true, SetPropertyMode set_mode = SET_PROPERTY);
// Returns the index'th element.
// The undefined object if index is out of bounds.
bool continue_search);
MUST_USE_RESULT static MaybeHandle<Object> SetElementWithCallback(
Handle<Object> object, Handle<Object> structure, uint32_t index,
- Handle<Object> value, Handle<JSObject> holder, StrictMode strict_mode);
+ Handle<Object> value, Handle<JSObject> holder,
+ LanguageMode language_mode);
MUST_USE_RESULT static MaybeHandle<Object> SetElementWithInterceptor(
- Handle<JSObject> object,
- uint32_t index,
- Handle<Object> value,
- PropertyAttributes attributes,
- StrictMode strict_mode,
- bool check_prototype,
- SetPropertyMode set_mode);
+ Handle<JSObject> object, uint32_t index, Handle<Object> value,
+ PropertyAttributes attributes, LanguageMode language_mode,
+ bool check_prototype, SetPropertyMode set_mode);
MUST_USE_RESULT static MaybeHandle<Object> SetElementWithoutInterceptor(
- Handle<JSObject> object,
- uint32_t index,
- Handle<Object> value,
- PropertyAttributes attributes,
- StrictMode strict_mode,
- bool check_prototype,
- SetPropertyMode set_mode);
+ Handle<JSObject> object, uint32_t index, Handle<Object> value,
+ PropertyAttributes attributes, LanguageMode language_mode,
+ bool check_prototype, SetPropertyMode set_mode);
MUST_USE_RESULT
static MaybeHandle<Object> SetElementWithCallbackSetterInPrototypes(
- Handle<JSObject> object,
- uint32_t index,
- Handle<Object> value,
- bool* found,
- StrictMode strict_mode);
+ Handle<JSObject> object, uint32_t index, Handle<Object> value,
+ bool* found, LanguageMode language_mode);
MUST_USE_RESULT static MaybeHandle<Object> SetDictionaryElement(
- Handle<JSObject> object,
- uint32_t index,
- Handle<Object> value,
- PropertyAttributes attributes,
- StrictMode strict_mode,
- bool check_prototype,
- SetPropertyMode set_mode = SET_PROPERTY);
+ Handle<JSObject> object, uint32_t index, Handle<Object> value,
+ PropertyAttributes attributes, LanguageMode language_mode,
+ bool check_prototype, SetPropertyMode set_mode = SET_PROPERTY);
MUST_USE_RESULT static MaybeHandle<Object> SetFastDoubleElement(
- Handle<JSObject> object,
- uint32_t index,
- Handle<Object> value,
- StrictMode strict_mode,
- bool check_prototype = true);
+ Handle<JSObject> object, uint32_t index, Handle<Object> value,
+ LanguageMode language_mode, bool check_prototype = true);
MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithFailedAccessCheck(
- LookupIterator* it, Handle<Object> value, StrictMode strict_mode);
+ LookupIterator* it, Handle<Object> value, LanguageMode language_mode);
// Add a property to a slow-case object.
static void AddSlowProperty(Handle<JSObject> object,
PropertyAttributes attributes);
MUST_USE_RESULT static MaybeHandle<Object> DeleteProperty(
- Handle<JSObject> object, Handle<Name> name, StrictMode strict_mode);
+ Handle<JSObject> object, Handle<Name> name, LanguageMode language_mode);
MUST_USE_RESULT static MaybeHandle<Object> DeletePropertyWithInterceptor(
Handle<JSObject> holder, Handle<JSObject> receiver, Handle<Name> name);
Handle<Name> name);
MUST_USE_RESULT static MaybeHandle<Object> DeleteElement(
- Handle<JSObject> object, uint32_t index, StrictMode strict_mode);
+ Handle<JSObject> object, uint32_t index, LanguageMode language_mode);
MUST_USE_RESULT static MaybeHandle<Object> DeleteElementWithInterceptor(
Handle<JSObject> object,
uint32_t index);
// Does this scope call eval?
bool CallsEval();
- // Return the strict mode of this scope.
- StrictMode strict_mode();
+ // Return the language mode of this scope.
+ LanguageMode language_mode();
// Does this scope make a sloppy eval call?
- bool CallsSloppyEval() { return CallsEval() && strict_mode() == SLOPPY; }
+ bool CallsSloppyEval() { return CallsEval() && is_sloppy(language_mode()); }
// Return the total number of locals allocated on the stack and in the
// context. This includes the parameters that are allocated in the context.
// Properties of scopes.
class ScopeTypeField : public BitField<ScopeType, 0, 4> {};
class CallsEvalField : public BitField<bool, 4, 1> {};
- class StrictModeField : public BitField<StrictMode, 5, 1> {};
+ STATIC_ASSERT(LANGUAGE_END == 2);
+ class LanguageModeField : public BitField<LanguageMode, 5, 1> {};
class FunctionVariableField : public BitField<FunctionVariableInfo, 6, 2> {};
class FunctionVariableMode : public BitField<VariableMode, 8, 3> {};
class AsmModuleField : public BitField<bool, 11, 1> {};
DECL_BOOLEAN_ACCESSORS(optimization_disabled)
// Indicates the language mode.
- inline StrictMode strict_mode();
- inline void set_strict_mode(StrictMode strict_mode);
+ inline LanguageMode language_mode();
+ inline void set_language_mode(LanguageMode language_mode);
// False if the function definitely does not allocate an arguments object.
DECL_BOOLEAN_ACCESSORS(uses_arguments)
kDeserialized,
kCompilerHintsCount // Pseudo entry
};
+ // Add hints for other modes when they're added.
+ STATIC_ASSERT(LANGUAGE_END == 2);
class FunctionKindBits : public BitField<FunctionKind, kIsArrow, 5> {};
Handle<Object> Lookup(Handle<String> src, Handle<Context> context);
Handle<Object> LookupEval(Handle<String> src,
Handle<SharedFunctionInfo> shared,
- StrictMode strict_mode, int scope_position);
+ LanguageMode language_mode, int scope_position);
Handle<Object> LookupRegExp(Handle<String> source, JSRegExp::Flags flags);
static Handle<CompilationCacheTable> Put(
Handle<CompilationCacheTable> cache, Handle<String> src,
MUST_USE_RESULT
static MaybeHandle<Object> SetPropertyViaPrototypesWithHandler(
Handle<JSProxy> proxy, Handle<Object> receiver, Handle<Name> name,
- Handle<Object> value, StrictMode strict_mode, bool* done);
+ Handle<Object> value, LanguageMode language_mode, bool* done);
MUST_USE_RESULT static Maybe<PropertyAttributes>
GetPropertyAttributesWithHandler(Handle<JSProxy> proxy,
uint32_t index);
MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithHandler(
Handle<JSProxy> proxy, Handle<Object> receiver, Handle<Name> name,
- Handle<Object> value, StrictMode strict_mode);
+ Handle<Object> value, LanguageMode language_mode);
// Turn the proxy into an (empty) JSObject.
static void Fix(Handle<JSProxy> proxy);
friend class JSReceiver;
MUST_USE_RESULT static inline MaybeHandle<Object> SetElementWithHandler(
- Handle<JSProxy> proxy,
- Handle<JSReceiver> receiver,
- uint32_t index,
- Handle<Object> value,
- StrictMode strict_mode);
+ Handle<JSProxy> proxy, Handle<JSReceiver> receiver, uint32_t index,
+ Handle<Object> value, LanguageMode language_mode);
MUST_USE_RESULT static Maybe<bool> HasPropertyWithHandler(
Handle<JSProxy> proxy, Handle<Name> name);
Handle<JSProxy> proxy, uint32_t index);
MUST_USE_RESULT static MaybeHandle<Object> DeletePropertyWithHandler(
- Handle<JSProxy> proxy, Handle<Name> name, StrictMode strict_mode);
+ Handle<JSProxy> proxy, Handle<Name> name, LanguageMode language_mode);
MUST_USE_RESULT static MaybeHandle<Object> DeleteElementWithHandler(
- Handle<JSProxy> proxy, uint32_t index, StrictMode strict_mode);
+ Handle<JSProxy> proxy, uint32_t index, LanguageMode language_mode);
MUST_USE_RESULT Object* GetIdentityHash();
Scope* function_scope =
NewScope(scope, FUNCTION_SCOPE, FunctionKind::kDefaultConstructor);
- function_scope->SetStrictMode(STRICT);
+ function_scope->SetLanguageMode(
+ static_cast<LanguageMode>(scope->language_mode() | STRICT));
// Set start and end position to the same value
function_scope->set_start_position(pos);
function_scope->set_end_position(pos);
}
original_scope_ = *scope;
if (info->is_eval()) {
- if (!(*scope)->is_script_scope() || info->strict_mode() == STRICT) {
+ if (!(*scope)->is_script_scope() || is_strict(info->language_mode())) {
*scope = NewScope(*scope, EVAL_SCOPE);
}
} else if (info->is_global()) {
FunctionState function_state(&function_state_, &scope_, *scope,
&function_factory);
- scope_->SetStrictMode(info->strict_mode());
+ scope_->SetLanguageMode(info->language_mode());
ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone());
bool ok = true;
int beg_pos = scanner()->location().beg_pos;
ParseStatementList(body, Token::EOS, info->is_eval(), eval_scope, &ok);
}
- if (ok && strict_mode() == STRICT) {
+ if (ok && is_strict(language_mode())) {
CheckStrictOctalLiteral(beg_pos, scanner()->location().end_pos, &ok);
}
- if (ok && allow_harmony_scoping() && strict_mode() == STRICT) {
+ if (ok && allow_harmony_scoping() && is_strict(language_mode())) {
CheckConflictingVarDeclarations(scope_, &ok);
}
AstNodeFactory function_factory(ast_value_factory());
FunctionState function_state(&function_state_, &scope_, scope,
&function_factory);
- DCHECK(scope->strict_mode() == SLOPPY || info()->strict_mode() == STRICT);
- DCHECK(info()->strict_mode() == shared_info->strict_mode());
- scope->SetStrictMode(shared_info->strict_mode());
+ DCHECK(is_sloppy(scope->language_mode()) ||
+ is_strict(info()->language_mode()));
+ DCHECK(info()->language_mode() == shared_info->language_mode());
+ scope->SetLanguageMode(shared_info->language_mode());
FunctionLiteral::FunctionType function_type = shared_info->is_expression()
? (shared_info->is_anonymous()
? FunctionLiteral::ANONYMOUS_EXPRESSION
literal->raw_value()->IsString()) {
// Check "use strict" directive (ES5 14.1) and "use asm" directive. Only
// one can be present.
- if (strict_mode() == SLOPPY &&
+ if (is_sloppy(language_mode()) &&
literal->raw_value()->AsString() ==
ast_value_factory()->use_strict_string() &&
token_loc.end_pos - token_loc.beg_pos ==
}
mode_ = PARSE_EAGERLY;
}
- scope_->SetStrictMode(STRICT);
+ scope_->SetLanguageMode(
+ static_cast<LanguageMode>(scope_->language_mode() | STRICT));
// "use strict" is the only directive for now.
directive_prologue = false;
} else if (literal->raw_value()->AsString() ==
return ParseVariableStatement(kStatementListItem, NULL, ok);
case Token::LET:
DCHECK(allow_harmony_scoping());
- if (strict_mode() == STRICT) {
+ if (is_strict(language_mode())) {
return ParseVariableStatement(kStatementListItem, NULL, ok);
}
// Fall through.
Scope* scope = NewScope(scope_, MODULE_SCOPE);
scope->set_start_position(scanner()->location().beg_pos);
- scope->SetStrictMode(STRICT);
+ scope->SetLanguageMode(
+ static_cast<LanguageMode>(scope->language_mode() | STRICT));
{
BlockState block_state(&scope_, scope);
// In Harmony mode, this case also handles the extension:
// Statement:
// GeneratorDeclaration
- if (strict_mode() == STRICT) {
+ if (is_strict(language_mode())) {
ReportMessageAt(scanner()->peek_location(), "strict_function");
*ok = false;
return NULL;
// In ES6 CONST is not allowed as a Statement, only as a
// LexicalDeclaration, however we continue to allow it in sloppy mode for
// backwards compatibility.
- if (strict_mode() == SLOPPY) {
+ if (is_sloppy(language_mode())) {
return ParseVariableStatement(kStatement, NULL, ok);
}
// because the var declaration is hoisted to the function scope where 'x'
// is already bound.
DCHECK(IsDeclaredVariableMode(var->mode()));
- if (allow_harmony_scoping() && strict_mode() == STRICT) {
+ if (allow_harmony_scoping() && is_strict(language_mode())) {
// In harmony we treat re-declarations as early errors. See
// ES5 16 for a definition of early errors.
ParserTraits::ReportMessage("var_redeclaration", name);
Variable(declaration_scope, name, mode, true, kind,
kNeedsInitialization, kNotAssigned, proxy->interface());
} else if (declaration_scope->is_eval_scope() &&
- declaration_scope->strict_mode() == SLOPPY) {
+ is_sloppy(declaration_scope->language_mode())) {
// For variable declarations in a sloppy eval scope the proxy is bound
// to a lookup variable to force a dynamic declaration using the
// DeclareLookupSlot runtime function.
// In ES6, a function behaves as a lexical binding, except in
// a script scope, or the initial scope of eval or another function.
VariableMode mode =
- allow_harmony_scoping() && strict_mode() == STRICT &&
- !(scope_->is_script_scope() || scope_->is_eval_scope() ||
- scope_->is_function_scope()) ? LET : VAR;
+ allow_harmony_scoping() && is_strict(language_mode()) &&
+ !(scope_->is_script_scope() || scope_->is_eval_scope() ||
+ scope_->is_function_scope())
+ ? LET
+ : VAR;
VariableProxy* proxy = NewUnresolved(name, mode, Interface::NewValue());
Declaration* declaration =
factory()->NewFunctionDeclaration(proxy, mode, fun, scope_, pos);
// so rewrite it as such.
Expect(Token::CLASS, CHECK_OK);
- if (!allow_harmony_sloppy() && strict_mode() == SLOPPY) {
+ if (!allow_harmony_sloppy() && is_sloppy(language_mode())) {
ReportMessage("sloppy_lexical");
*ok = false;
return NULL;
Block* Parser::ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok) {
- if (allow_harmony_scoping() && strict_mode() == STRICT) {
+ if (allow_harmony_scoping() && is_strict(language_mode())) {
return ParseScopedBlock(labels, ok);
}
Consume(Token::VAR);
} else if (peek() == Token::CONST) {
Consume(Token::CONST);
- switch (strict_mode()) {
- case SLOPPY:
- mode = CONST_LEGACY;
- init_op = Token::INIT_CONST_LEGACY;
- break;
- case STRICT:
- DCHECK(var_context != kStatement);
- // In ES5 const is not allowed in strict mode.
- if (!allow_harmony_scoping()) {
- ReportMessage("strict_const");
- *ok = false;
- return NULL;
- }
- mode = CONST;
- init_op = Token::INIT_CONST;
+ if (is_sloppy(language_mode())) {
+ mode = CONST_LEGACY;
+ init_op = Token::INIT_CONST_LEGACY;
+ } else {
+ DCHECK(var_context != kStatement);
+ // In ES5 const is not allowed in strict mode.
+ if (!allow_harmony_scoping()) {
+ ReportMessage("strict_const");
+ *ok = false;
+ return NULL;
+ }
+ mode = CONST;
+ init_op = Token::INIT_CONST;
}
is_const = true;
needs_init = true;
- } else if (peek() == Token::LET && strict_mode() == STRICT) {
+ } else if (peek() == Token::LET && is_strict(language_mode())) {
DCHECK(allow_harmony_scoping());
Consume(Token::LET);
DCHECK(var_context != kStatement);
Runtime::FunctionForId(Runtime::kInitializeConstGlobal), arguments,
pos);
} else {
- // Add strict mode.
+ // Add language mode.
// We may want to pass singleton to avoid Literal allocations.
- StrictMode strict_mode = initialization_scope->strict_mode();
- arguments->Add(factory()->NewNumberLiteral(strict_mode, pos), zone());
+ LanguageMode language_mode = initialization_scope->language_mode();
+ arguments->Add(factory()->NewNumberLiteral(language_mode, pos), zone());
// Be careful not to assign a value to the global variable if
// we're in a with. The initialization value should not
Expect(Token::WITH, CHECK_OK);
int pos = position();
- if (strict_mode() == STRICT) {
+ if (is_strict(language_mode())) {
ReportMessage("strict_mode_with");
*ok = false;
return NULL;
bool is_let_identifier_expression = false;
if (peek() != Token::SEMICOLON) {
if (peek() == Token::VAR ||
- (peek() == Token::CONST && strict_mode() == SLOPPY)) {
+ (peek() == Token::CONST && is_sloppy(language_mode()))) {
bool is_const = peek() == Token::CONST;
const AstRawString* name = NULL;
VariableDeclarationProperties decl_props = kHasNoInitializers;
init = variable_statement;
}
} else if ((peek() == Token::LET || peek() == Token::CONST) &&
- strict_mode() == STRICT) {
+ is_strict(language_mode())) {
bool is_const = peek() == Token::CONST;
const AstRawString* name = NULL;
VariableDeclarationProperties decl_props = kHasNoInitializers;
// Parsed initializer at this point.
// Detect attempts at 'let' declarations in sloppy mode.
- if (peek() == Token::IDENTIFIER && strict_mode() == SLOPPY &&
+ if (peek() == Token::IDENTIFIER && is_sloppy(language_mode()) &&
is_let_identifier_expression) {
ReportMessage("sloppy_lexical", NULL);
*ok = false;
Scope* original_declaration_scope = original_scope_->DeclarationScope();
Scope* scope =
function_type == FunctionLiteral::DECLARATION &&
- (!allow_harmony_scoping() || strict_mode() == SLOPPY) &&
+ (!allow_harmony_scoping() || is_sloppy(language_mode())) &&
(original_scope_ == original_declaration_scope ||
declaration_scope != original_declaration_scope)
? NewScope(declaration_scope, FUNCTION_SCOPE, kind)
}
Variable* var = scope_->DeclareParameter(param_name, VAR, is_rest);
- if (scope->strict_mode() == SLOPPY) {
+ if (is_sloppy(scope->language_mode())) {
// TODO(sigurds) Mark every parameter as maybe assigned. This is a
// conservative approximation necessary to account for parameters
// that are assigned via the arguments array.
Variable* fvar = NULL;
Token::Value fvar_init_op = Token::INIT_CONST_LEGACY;
if (function_type == FunctionLiteral::NAMED_EXPRESSION) {
- if (allow_harmony_scoping() && strict_mode() == STRICT) {
+ if (allow_harmony_scoping() && is_strict(language_mode())) {
fvar_init_op = Token::INIT_CONST;
}
VariableMode fvar_mode =
- allow_harmony_scoping() && strict_mode() == STRICT
- ? CONST : CONST_LEGACY;
+ allow_harmony_scoping() && is_strict(language_mode()) ? CONST
+ : CONST_LEGACY;
DCHECK(function_name != NULL);
fvar = new (zone())
Variable(scope_, function_name, fvar_mode, true /* is valid LHS */,
// Concise methods use StrictFormalParameters.
// Functions for which IsSimpleParameterList() returns false use
// StrictFormalParameters.
- if (strict_mode() == STRICT || IsConciseMethod(kind) || is_rest) {
+ if (is_strict(language_mode()) || IsConciseMethod(kind) || is_rest) {
CheckStrictFunctionNameAndParameters(function_name,
name_is_strict_reserved,
function_name_location,
reserved_loc,
CHECK_OK);
}
- if (strict_mode() == STRICT) {
+ if (is_strict(language_mode())) {
CheckStrictOctalLiteral(scope->start_position(), scope->end_position(),
CHECK_OK);
}
- if (allow_harmony_scoping() && strict_mode() == STRICT) {
+ if (allow_harmony_scoping() && is_strict(language_mode())) {
CheckConflictingVarDeclarations(scope, CHECK_OK);
}
}
total_preparse_skipped_ += scope_->end_position() - function_block_pos;
*materialized_literal_count = entry.literal_count();
*expected_property_count = entry.property_count();
- scope_->SetStrictMode(entry.strict_mode());
+ scope_->SetLanguageMode(entry.language_mode());
return;
}
cached_parse_data_->Reject();
total_preparse_skipped_ += scope_->end_position() - function_block_pos;
*materialized_literal_count = logger.literals();
*expected_property_count = logger.properties();
- scope_->SetStrictMode(logger.strict_mode());
+ scope_->SetLanguageMode(logger.language_mode());
if (produce_cached_parse_data()) {
DCHECK(log_);
// Position right after terminal '}'.
int body_end = scanner()->location().end_pos;
log_->LogFunction(function_block_pos, body_end, *materialized_literal_count,
- *expected_property_count, scope_->strict_mode());
+ *expected_property_count, scope_->language_mode());
}
}
reusable_preparser_->set_allow_harmony_rest_params(
allow_harmony_rest_params());
}
- PreParser::PreParseResult result =
- reusable_preparser_->PreParseLazyFunction(strict_mode(),
- is_generator(),
- logger);
+ PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction(
+ language_mode(), is_generator(), logger);
if (pre_parse_timer_ != NULL) {
pre_parse_timer_->Stop();
}
Scope* block_scope = NewScope(scope_, BLOCK_SCOPE);
BlockState block_state(&scope_, block_scope);
- scope_->SetStrictMode(STRICT);
+ scope_->SetLanguageMode(
+ static_cast<LanguageMode>(scope_->language_mode() | STRICT));
scope_->SetScopeName(name);
VariableProxy* proxy = NULL;
kEndPositionIndex,
kLiteralCountIndex,
kPropertyCountIndex,
- kStrictModeIndex,
+ kLanguageModeIndex,
kSize
};
int end_pos() { return backing_[kEndPositionIndex]; }
int literal_count() { return backing_[kLiteralCountIndex]; }
int property_count() { return backing_[kPropertyCountIndex]; }
- StrictMode strict_mode() {
- DCHECK(backing_[kStrictModeIndex] == SLOPPY ||
- backing_[kStrictModeIndex] == STRICT);
- return static_cast<StrictMode>(backing_[kStrictModeIndex]);
+ LanguageMode language_mode() {
+ DCHECK(is_valid_language_mode(backing_[kLanguageModeIndex]));
+ return static_cast<LanguageMode>(backing_[kLanguageModeIndex]);
}
bool is_valid() { return !backing_.is_empty(); }
Parser parser(info, &parse_info);
parser.set_allow_lazy(allow_lazy);
if (parser.Parse()) {
- info->SetStrictMode(info->function()->strict_mode());
+ info->SetLanguageMode(info->function()->language_mode());
return true;
}
return false;
virtual ~ParserRecorder() { }
// Logs the scope and some details of a function literal in the source.
- virtual void LogFunction(int start,
- int end,
- int literals,
- int properties,
- StrictMode strict_mode) = 0;
+ virtual void LogFunction(int start, int end, int literals, int properties,
+ LanguageMode language_mode) = 0;
// Logs an error message and marks the log as containing an error.
// Further logging will be ignored, and ExtractData will return a vector
void Reset() { has_error_ = false; }
- virtual void LogFunction(int start,
- int end,
- int literals,
- int properties,
- StrictMode strict_mode) {
+ virtual void LogFunction(int start, int end, int literals, int properties,
+ LanguageMode language_mode) {
DCHECK(!has_error_);
start_ = start;
end_ = end;
literals_ = literals;
properties_ = properties;
- strict_mode_ = strict_mode;
+ language_mode_ = language_mode;
}
// Logs an error message and marks the log as containing an error.
DCHECK(!has_error_);
return properties_;
}
- StrictMode strict_mode() const {
+ LanguageMode language_mode() const {
DCHECK(!has_error_);
- return strict_mode_;
+ return language_mode_;
}
int is_reference_error() const { return is_reference_error_; }
const char* message() {
// For function entries.
int literals_;
int properties_;
- StrictMode strict_mode_;
+ LanguageMode language_mode_;
// For error messages.
const char* message_;
const char* argument_opt_;
CompleteParserRecorder();
virtual ~CompleteParserRecorder() {}
- virtual void LogFunction(int start,
- int end,
- int literals,
- int properties,
- StrictMode strict_mode) {
+ virtual void LogFunction(int start, int end, int literals, int properties,
+ 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.
PreParser::PreParseResult PreParser::PreParseLazyFunction(
- StrictMode strict_mode, bool is_generator, ParserRecorder* log) {
+ LanguageMode language_mode, bool is_generator, ParserRecorder* log) {
log_ = log;
// Lazy functions always have trivial outer scopes (no with/catch scopes).
PreParserScope top_scope(scope_, SCRIPT_SCOPE);
PreParserFactory top_factory(NULL);
FunctionState top_state(&function_state_, &scope_, &top_scope, &top_factory);
- scope_->SetStrictMode(strict_mode);
+ scope_->SetLanguageMode(language_mode);
PreParserScope function_scope(scope_, FUNCTION_SCOPE);
PreParserFactory function_factory(NULL);
FunctionState function_state(&function_state_, &scope_, &function_scope,
ReportUnexpectedToken(scanner()->current_token());
} else {
DCHECK_EQ(Token::RBRACE, scanner()->peek());
- if (scope_->strict_mode() == STRICT) {
+ if (is_strict(scope_->language_mode())) {
int end_pos = scanner()->location().end_pos;
CheckStrictOctalLiteral(start_position, end_pos, &ok);
}
return ParseVariableStatement(kSourceElement, ok);
case Token::LET:
DCHECK(allow_harmony_scoping());
- if (strict_mode() == STRICT) {
+ if (is_strict(language_mode())) {
return ParseVariableStatement(kSourceElement, ok);
}
// Fall through.
Statement statement = ParseSourceElement(CHECK_OK);
if (directive_prologue) {
if (statement.IsUseStrictLiteral()) {
- scope_->SetStrictMode(STRICT);
+ scope_->SetLanguageMode(
+ static_cast<LanguageMode>(scope_->language_mode() | STRICT));
} else if (!statement.IsStringLiteral()) {
directive_prologue = false;
}
Scanner::Location start_location = scanner()->peek_location();
Statement statement = ParseFunctionDeclaration(CHECK_OK);
Scanner::Location end_location = scanner()->location();
- if (strict_mode() == STRICT) {
+ if (is_strict(language_mode())) {
PreParserTraits::ReportMessageAt(start_location.beg_pos,
end_location.end_pos,
"strict_function");
// In ES6 CONST is not allowed as a Statement, only as a
// LexicalDeclaration, however we continue to allow it in sloppy mode for
// backwards compatibility.
- if (strict_mode() == SLOPPY) {
+ if (is_sloppy(language_mode())) {
return ParseVariableStatement(kStatement, ok);
}
PreParser::Statement PreParser::ParseClassDeclaration(bool* ok) {
Expect(Token::CLASS, CHECK_OK);
- if (!allow_harmony_sloppy() && strict_mode() == SLOPPY) {
+ if (!allow_harmony_sloppy() && is_sloppy(language_mode())) {
ReportMessage("sloppy_lexical");
*ok = false;
return Statement::Default();
//
Expect(Token::LBRACE, CHECK_OK);
while (peek() != Token::RBRACE) {
- if (allow_harmony_scoping() && strict_mode() == STRICT) {
+ if (allow_harmony_scoping() && is_strict(language_mode())) {
ParseSourceElement(CHECK_OK);
} else {
ParseStatement(CHECK_OK);
// existing pages. Therefore we keep allowing const with the old
// non-harmony semantics in sloppy mode.
Consume(Token::CONST);
- if (strict_mode() == STRICT) {
+ if (is_strict(language_mode())) {
DCHECK(var_context != kStatement);
if (!allow_harmony_scoping()) {
Scanner::Location location = scanner()->peek_location();
is_strict_const = true;
require_initializer = var_context != kForStatement;
}
- } else if (peek() == Token::LET && strict_mode() == STRICT) {
+ } else if (peek() == Token::LET && is_strict(language_mode())) {
Consume(Token::LET);
DCHECK(var_context != kStatement);
} else {
// Expression is a single identifier, and not, e.g., a parenthesized
// identifier.
DCHECK(!expr.AsIdentifier().IsFutureReserved());
- DCHECK(strict_mode() == SLOPPY ||
+ DCHECK(is_sloppy(language_mode()) ||
!IsFutureStrictReserved(expr.AsIdentifier()));
Consume(Token::COLON);
return ParseStatement(ok);
}
// Parsed expression statement.
// Detect attempts at 'let' declarations in sloppy mode.
- if (peek() == Token::IDENTIFIER && strict_mode() == SLOPPY &&
+ if (peek() == Token::IDENTIFIER && is_sloppy(language_mode()) &&
expr.IsIdentifier() && expr.AsIdentifier().IsLet()) {
ReportMessage("sloppy_lexical", NULL);
*ok = false;
// WithStatement ::
// 'with' '(' Expression ')' Statement
Expect(Token::WITH, CHECK_OK);
- if (strict_mode() == STRICT) {
+ if (is_strict(language_mode())) {
ReportMessageAt(scanner()->location(), "strict_mode_with");
*ok = false;
return Statement::Default();
bool is_let_identifier_expression = false;
if (peek() != Token::SEMICOLON) {
if (peek() == Token::VAR || peek() == Token::CONST ||
- (peek() == Token::LET && strict_mode() == STRICT)) {
+ (peek() == Token::LET && is_strict(language_mode()))) {
bool is_lexical = peek() == Token::LET ||
- (peek() == Token::CONST && strict_mode() == STRICT);
+ (peek() == Token::CONST && is_strict(language_mode()));
int decl_count;
VariableDeclarationProperties decl_props = kHasNoInitializers;
ParseVariableDeclarations(
// Parsed initializer at this point.
// Detect attempts at 'let' declarations in sloppy mode.
- if (peek() == Token::IDENTIFIER && strict_mode() == SLOPPY &&
+ if (peek() == Token::IDENTIFIER && is_sloppy(language_mode()) &&
is_let_identifier_expression) {
ReportMessage("sloppy_lexical", NULL);
*ok = false;
// Validate strict mode. We can do this only after parsing the function,
// since the function can declare itself strict.
// Concise methods use StrictFormalParameters.
- if (strict_mode() == STRICT || IsConciseMethod(kind) || is_rest) {
+ if (is_strict(language_mode()) || IsConciseMethod(kind) || is_rest) {
if (function_name.IsEvalOrArguments()) {
ReportMessageAt(function_name_location, "strict_eval_arguments");
*ok = false;
// Position right after terminal '}'.
DCHECK_EQ(Token::RBRACE, scanner()->peek());
int body_end = scanner()->peek_location().end_pos;
- log_->LogFunction(body_start, body_end,
- function_state_->materialized_literal_count(),
- function_state_->expected_property_count(),
- strict_mode());
+ log_->LogFunction(
+ body_start, body_end, function_state_->materialized_literal_count(),
+ function_state_->expected_property_count(), language_mode());
}
PreParserScope scope = NewScope(scope_, BLOCK_SCOPE);
BlockState block_state(&scope_, &scope);
- scope_->SetStrictMode(STRICT);
+ scope_->SetLanguageMode(
+ static_cast<LanguageMode>(scope_->language_mode() | STRICT));
scope_->SetScopeName(name);
bool has_extends = Check(Token::EXTENDS);
return function_state_->factory();
}
- StrictMode strict_mode() { return scope_->strict_mode(); }
+ LanguageMode language_mode() { return scope_->language_mode(); }
bool is_generator() const { return function_state_->is_generator(); }
// Report syntax errors.
explicit PreParserScope(PreParserScope* outer_scope, ScopeType scope_type,
void* = NULL)
: scope_type_(scope_type) {
- strict_mode_ = outer_scope ? outer_scope->strict_mode() : SLOPPY;
+ language_mode_ = outer_scope ? outer_scope->language_mode() : SLOPPY;
}
ScopeType type() { return scope_type_; }
- StrictMode strict_mode() const { return strict_mode_; }
- void SetStrictMode(StrictMode strict_mode) { strict_mode_ = strict_mode; }
+ LanguageMode language_mode() const { return language_mode_; }
+ void SetLanguageMode(LanguageMode language_mode) {
+ language_mode_ = language_mode;
+ }
void SetScopeName(PreParserIdentifier name) {}
// When PreParser is in use, lazy compilation is already being done,
private:
ScopeType scope_type_;
- StrictMode strict_mode_;
+ LanguageMode language_mode_;
};
if (stack_overflow()) return kPreParseStackOverflow;
if (!ok) {
ReportUnexpectedToken(scanner()->current_token());
- } else if (scope_->strict_mode() == STRICT) {
+ } else if (is_strict(scope_->language_mode())) {
CheckStrictOctalLiteral(start_position, scanner()->location().end_pos,
&ok);
}
// keyword and parameters, and have consumed the initial '{'.
// At return, unless an error occurred, the scanner is positioned before the
// the final '}'.
- PreParseResult PreParseLazyFunction(StrictMode strict_mode,
- bool is_generator,
- ParserRecorder* log);
+ PreParseResult PreParseLazyFunction(LanguageMode language_mode,
+ bool is_generator, ParserRecorder* log);
private:
friend class PreParserTraits;
case Token::STATIC:
case Token::YIELD:
case Token::FUTURE_STRICT_RESERVED_WORD:
- return ReportMessageAt(source_location, strict_mode() == SLOPPY
- ? "unexpected_token_identifier" : "unexpected_strict_reserved");
+ return ReportMessageAt(source_location,
+ is_strict(language_mode())
+ ? "unexpected_strict_reserved"
+ : "unexpected_token_identifier");
case Token::TEMPLATE_SPAN:
case Token::TEMPLATE_TAIL:
return Traits::ReportMessageAt(source_location,
if (next == Token::IDENTIFIER) {
IdentifierT name = this->GetSymbol(scanner());
if (allow_eval_or_arguments == kDontAllowEvalOrArguments &&
- strict_mode() == STRICT && this->IsEvalOrArguments(name)) {
+ is_strict(language_mode()) && this->IsEvalOrArguments(name)) {
ReportMessage("strict_eval_arguments");
*ok = false;
}
if (name->IsArguments(this->ast_value_factory()))
scope_->RecordArgumentsUsage();
return name;
- } else if (strict_mode() == SLOPPY &&
+ } else if (is_sloppy(language_mode()) &&
(next == Token::FUTURE_STRICT_RESERVED_WORD ||
next == Token::LET || next == Token::STATIC ||
(next == Token::YIELD && !is_generator()))) {
case Token::CLASS: {
Consume(Token::CLASS);
- if (!allow_harmony_sloppy() && strict_mode() == SLOPPY) {
+ if (!allow_harmony_sloppy() && is_sloppy(language_mode())) {
ReportMessage("sloppy_lexical", NULL);
*ok = false;
break;
is_static, *is_computed_name);
} else if (!in_class && allow_harmony_object_literals_ &&
- Token::IsIdentifier(name_token, strict_mode(),
+ Token::IsIdentifier(name_token, language_mode(),
this->is_generator())) {
DCHECK(!*is_computed_name);
DCHECK(!is_static);
ExpressionT expression = ParseUnaryExpression(CHECK_OK);
// "delete identifier" is a syntax error in strict mode.
- if (op == Token::DELETE && strict_mode() == STRICT &&
+ if (op == Token::DELETE && is_strict(language_mode()) &&
this->IsIdentifier(expression)) {
ReportMessage("strict_delete");
*ok = false;
CHECK_OK);
// Validate strict mode.
- if (strict_mode() == STRICT) {
+ if (is_strict(language_mode())) {
CheckStrictOctalLiteral(start_pos, scanner()->location().end_pos,
CHECK_OK);
}
- if (allow_harmony_scoping() && strict_mode() == STRICT)
+ if (allow_harmony_scoping() && is_strict(language_mode()))
this->CheckConflictingVarDeclarations(scope, CHECK_OK);
}
Traits>::CheckAndRewriteReferenceExpression(ExpressionT expression,
Scanner::Location location,
const char* message, bool* ok) {
- if (strict_mode() == STRICT && this->IsIdentifier(expression) &&
+ if (is_strict(language_mode()) && this->IsIdentifier(expression) &&
this->IsEvalOrArguments(this->AsIdentifier(expression))) {
this->ReportMessageAt(location, "strict_eval_arguments", false);
*ok = false;
*/
// ECMA-262, section 11.4.1, page 46.
-function DELETE(key, strict) {
- return %DeleteProperty(%ToObject(this), %ToName(key), strict);
+function DELETE(key, language_mode) {
+ return %DeleteProperty(%ToObject(this), %ToName(key), language_mode);
}
static Object* StoreToSuper(Isolate* isolate, Handle<JSObject> home_object,
Handle<Object> receiver, Handle<Name> name,
- Handle<Object> value, StrictMode strict_mode) {
+ Handle<Object> value, LanguageMode language_mode) {
if (home_object->IsAccessCheckNeeded() &&
!isolate->MayNamedAccess(home_object, name, v8::ACCESS_SET)) {
isolate->ReportFailedAccessCheck(home_object, v8::ACCESS_SET);
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
- Object::SetProperty(&it, value, strict_mode,
+ Object::SetProperty(&it, value, language_mode,
Object::CERTAINLY_NOT_STORE_FROM_KEYED,
Object::SUPER_PROPERTY));
return *result;
Handle<JSObject> home_object,
Handle<Object> receiver, uint32_t index,
Handle<Object> value,
- StrictMode strict_mode) {
+ LanguageMode language_mode) {
if (home_object->IsAccessCheckNeeded() &&
!isolate->MayIndexedAccess(home_object, index, v8::ACCESS_SET)) {
isolate->ReportFailedAccessCheck(home_object, v8::ACCESS_SET);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
Object::SetElementWithReceiver(isolate, proto, receiver, index, value,
- strict_mode));
+ language_mode));
return *result;
}
static Object* StoreKeyedToSuper(Isolate* isolate, Handle<JSObject> home_object,
Handle<Object> receiver, Handle<Object> key,
- Handle<Object> value, StrictMode strict_mode) {
+ Handle<Object> value,
+ LanguageMode language_mode) {
uint32_t index;
if (key->ToArrayIndex(&index)) {
return StoreElementToSuper(isolate, home_object, receiver, index, value,
- strict_mode);
+ language_mode);
}
Handle<Name> name;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name,
Runtime::ToName(isolate, key));
if (name->AsArrayIndex(&index)) {
return StoreElementToSuper(isolate, home_object, receiver, index, value,
- strict_mode);
+ language_mode);
}
- return StoreToSuper(isolate, home_object, receiver, name, value, strict_mode);
+ return StoreToSuper(isolate, home_object, receiver, name, value,
+ language_mode);
}
static ObjectPair CompileGlobalEval(Isolate* isolate, Handle<String> source,
Handle<SharedFunctionInfo> outer_info,
Handle<Object> receiver,
- StrictMode strict_mode,
+ LanguageMode language_mode,
int scope_position) {
Handle<Context> context = Handle<Context>(isolate->context());
Handle<Context> native_context = Handle<Context>(context->native_context());
Handle<JSFunction> compiled;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, compiled,
- Compiler::GetFunctionFromEval(source, outer_info, context, strict_mode,
+ Compiler::GetFunctionFromEval(source, outer_info, context, language_mode,
restriction, scope_position),
MakePair(isolate->heap()->exception(), NULL));
return MakePair(*compiled, *receiver);
}
DCHECK(args[4]->IsSmi());
- DCHECK(args.smi_at(4) == SLOPPY || args.smi_at(4) == STRICT);
- StrictMode strict_mode = static_cast<StrictMode>(args.smi_at(4));
+ DCHECK(is_valid_language_mode(args.smi_at(4)));
+ LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(4));
DCHECK(args[5]->IsSmi());
Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(),
isolate);
return CompileGlobalEval(isolate, args.at<String>(1), outer_info,
- args.at<Object>(3), strict_mode, args.smi_at(5));
+ args.at<Object>(3), language_mode, args.smi_at(5));
}
}
} // namespace v8::internal
// 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() == SLOPPY &&
+ if (!receiver->IsJSObject() && is_sloppy(shared->language_mode()) &&
!function->IsBuiltin()) {
// If the receiver is not a JSObject and the function is not a
// builtin or strict-mode we have hit an optimization where a
}
JSFunction* function = JSFunction::cast(callable);
SharedFunctionInfo* shared = function->shared();
- return isolate->heap()->ToBoolean(shared->strict_mode() == SLOPPY);
+ return isolate->heap()->ToBoolean(is_sloppy(shared->language_mode()));
}
JSFunction* function = JSFunction::cast(callable);
SharedFunctionInfo* shared = function->shared();
- if (shared->native() || shared->strict_mode() == STRICT) {
+ if (shared->native() || is_strict(shared->language_mode())) {
return isolate->heap()->undefined_value();
}
// Returns undefined for strict or native functions, or
Handle<Object> object,
Handle<Object> key,
Handle<Object> value,
- StrictMode strict_mode) {
+ LanguageMode language_mode) {
if (object->IsUndefined() || object->IsNull()) {
Handle<Object> args[2] = {key, object};
THROW_NEW_ERROR(isolate, NewTypeError("non_object_property_store",
}
Handle<Name> name = Handle<Name>::cast(name_object);
return Object::SetProperty(Handle<JSProxy>::cast(object), name, value,
- strict_mode);
+ language_mode);
}
// Check if the given key is an array index.
}
MaybeHandle<Object> result = JSObject::SetElement(
- js_object, index, value, NONE, strict_mode, true, SET_PROPERTY);
+ js_object, index, value, NONE, language_mode, true, SET_PROPERTY);
JSObject::ValidateElements(js_object);
return result.is_null() ? result : value;
isolate, value, Execution::ToNumber(isolate, value), Object);
}
}
- return JSObject::SetElement(js_object, index, value, NONE, strict_mode,
+ return JSObject::SetElement(js_object, index, value, NONE, language_mode,
true, SET_PROPERTY);
} else {
if (name->IsString()) name = String::Flatten(Handle<String>::cast(name));
- return Object::SetProperty(object, name, value, strict_mode);
+ return Object::SetProperty(object, name, value, language_mode);
}
}
// TODO(verwaest): Support non-JSObject receivers.
if (!object->IsJSObject()) return value;
Handle<JSObject> js_object = Handle<JSObject>::cast(object);
- return JSObject::SetElement(js_object, index, value, NONE, strict_mode,
+ return JSObject::SetElement(js_object, index, value, NONE, language_mode,
true, SET_PROPERTY);
}
- return Object::SetProperty(object, name, value, strict_mode);
+ return Object::SetProperty(object, name, value, language_mode);
}
CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
- CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode_arg, 3);
- StrictMode strict_mode = strict_mode_arg;
+ CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode_arg, 3);
+ LanguageMode language_mode = language_mode_arg;
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
- Runtime::SetObjectProperty(isolate, object, key, value, strict_mode));
+ Runtime::SetObjectProperty(isolate, object, key, value, language_mode));
return *result;
}
DCHECK(args.length() == 3);
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0);
CONVERT_ARG_HANDLE_CHECKED(Name, key, 1);
- CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 2);
+ CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 2);
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, JSReceiver::DeleteProperty(object, key, strict_mode));
+ isolate, result, JSReceiver::DeleteProperty(object, key, language_mode));
return *result;
}
RUNTIME_ASSERT(args.length() == 3);
CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
- CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 1);
+ CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 1);
CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
Handle<GlobalObject> global(isolate->context()->global_object());
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, Object::SetProperty(global, name, value, strict_mode));
+ isolate, result, Object::SetProperty(global, name, value, language_mode));
return *result;
}
// Determine parameter location on the stack and dispatch on language mode.
int argument_count = frame->GetArgumentsLength();
Object** parameters = reinterpret_cast<Object**>(frame->GetParameterSlot(-1));
- return callee->shared()->strict_mode() == STRICT
+ return is_strict(callee->shared()->language_mode())
? *NewStrictArguments(isolate, callee, parameters, argument_count)
: *NewSloppyArguments(isolate, callee, parameters, argument_count);
}
CONVERT_ARG_HANDLE_CHECKED(Object, value, 0);
CONVERT_ARG_HANDLE_CHECKED(Context, context, 1);
CONVERT_ARG_HANDLE_CHECKED(String, name, 2);
- CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 3);
+ CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 3);
int index;
PropertyAttributes attributes;
if (index >= 0) {
if ((attributes & READ_ONLY) == 0) {
Handle<Context>::cast(holder)->set(index, *value);
- } else if (strict_mode == STRICT) {
+ } else if (is_strict(language_mode)) {
// Setting read only property in strict mode.
THROW_NEW_ERROR_RETURN_FAILURE(
isolate,
if (attributes != ABSENT) {
// The property exists on the holder.
object = Handle<JSReceiver>::cast(holder);
- } else if (strict_mode == STRICT) {
+ } else if (is_strict(language_mode)) {
// If absent in strict mode: throw.
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewReferenceError("not_defined", HandleVector(&name, 1)));
}
RETURN_FAILURE_ON_EXCEPTION(
- isolate, Object::SetProperty(object, name, value, strict_mode));
+ isolate, Object::SetProperty(object, name, value, language_mode));
return *value;
}
}
if (String::Equals(isolate->factory()->callee_string(), key)) {
JSFunction* function = frame->function();
- if (function->shared()->strict_mode() == STRICT) {
+ if (is_strict(function->shared()->language_mode())) {
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewTypeError("strict_arguments_callee",
HandleVector<Object>(NULL, 0)));
PropertyDetails name = PropertyDetails(Smi::cast(args[index]));
-// Assert that the given argument has a valid value for a StrictMode
-// and store it in a StrictMode variable with the given name.
-#define CONVERT_STRICT_MODE_ARG_CHECKED(name, index) \
- RUNTIME_ASSERT(args[index]->IsSmi()); \
- RUNTIME_ASSERT(args.smi_at(index) == STRICT || \
- args.smi_at(index) == SLOPPY); \
- StrictMode name = static_cast<StrictMode>(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_CHECKED(name, index) \
+ RUNTIME_ASSERT(args[index]->IsSmi()); \
+ RUNTIME_ASSERT(is_valid_language_mode(args.smi_at(index))); \
+ LanguageMode name = static_cast<LanguageMode>(args.smi_at(index));
// Assert that the given argument is a number within the Int32 range
MUST_USE_RESULT static MaybeHandle<Object> SetObjectProperty(
Isolate* isolate, Handle<Object> object, Handle<Object> key,
- Handle<Object> value, StrictMode strict_mode);
+ Handle<Object> value, LanguageMode language_mode);
MUST_USE_RESULT static MaybeHandle<Object> DefineObjectProperty(
Handle<JSObject> object, Handle<Object> key, Handle<Object> value,
class DeclareGlobalsEvalFlag : public BitField<bool, 0, 1> {};
class DeclareGlobalsNativeFlag : public BitField<bool, 1, 1> {};
-class DeclareGlobalsStrictMode : public BitField<StrictMode, 2, 1> {};
+STATIC_ASSERT(LANGUAGE_END == 2);
+class DeclareGlobalsLanguageMode : public BitField<LanguageMode, 2, 1> {};
} // namespace internal
} // namespace v8
// Encode the flags.
int flags = ScopeTypeField::encode(scope->scope_type()) |
CallsEvalField::encode(scope->calls_eval()) |
- StrictModeField::encode(scope->strict_mode()) |
+ LanguageModeField::encode(scope->language_mode()) |
FunctionVariableField::encode(function_name_info) |
FunctionVariableMode::encode(function_variable_mode) |
AsmModuleField::encode(scope->asm_module()) |
}
-StrictMode ScopeInfo::strict_mode() {
- return length() > 0 ? StrictModeField::decode(Flags()) : SLOPPY;
+LanguageMode ScopeInfo::language_mode() {
+ return length() > 0 ? LanguageModeField::decode(Flags()) : SLOPPY;
}
asm_module_ = false;
asm_function_ = outer_scope != NULL && outer_scope->asm_module_;
// Inherit the strict mode from the parent scope.
- strict_mode_ = outer_scope != NULL ? outer_scope->strict_mode_ : SLOPPY;
+ language_mode_ = outer_scope != NULL ? outer_scope->language_mode_ : SLOPPY;
outer_scope_calls_sloppy_eval_ = false;
inner_scope_calls_eval_ = false;
inner_scope_uses_arguments_ = false;
end_position_ = RelocInfo::kNoPosition;
if (!scope_info.is_null()) {
scope_calls_eval_ = scope_info->CallsEval();
- strict_mode_ = scope_info->strict_mode();
+ language_mode_ = scope_info->language_mode();
}
}
if (HasTrivialOuterContext()) {
Indent(n1, "// scope has trivial outer context\n");
}
- if (strict_mode() == STRICT) {
+ if (is_strict(language_mode())) {
Indent(n1, "// strict mode scope\n");
}
if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n");
// In strict mode 'arguments' does not alias formal parameters.
// Therefore in strict mode we allocate parameters as if 'arguments'
// were not used.
- uses_sloppy_arguments = strict_mode() == SLOPPY;
+ uses_sloppy_arguments = is_sloppy(language_mode());
}
if (rest_parameter_ && !MustAllocate(rest_parameter_)) {
// Inform the scope that the corresponding code uses "this".
void RecordThisUsage() { scope_uses_this_ = true; }
- // Set the strict mode flag (unless disabled by a global flag).
- void SetStrictMode(StrictMode strict_mode) { strict_mode_ = strict_mode; }
+ // Set the language mode flag (unless disabled by a global flag).
+ void SetLanguageMode(LanguageMode language_mode) {
+ language_mode_ = language_mode;
+ }
// Set the ASM module flag.
void SetAsmModule() { asm_module_ = true; }
is_module_scope() || is_script_scope();
}
bool is_strict_eval_scope() const {
- return is_eval_scope() && strict_mode_ == STRICT;
+ return is_eval_scope() && is_strict(language_mode_);
}
// Information about which scopes calls eval.
bool calls_eval() const { return scope_calls_eval_; }
bool calls_sloppy_eval() {
- return scope_calls_eval_ && strict_mode_ == SLOPPY;
+ return scope_calls_eval_ && is_sloppy(language_mode_);
}
bool outer_scope_calls_sloppy_eval() const {
return outer_scope_calls_sloppy_eval_;
ScopeType scope_type() const { return scope_type_; }
// The language mode of this scope.
- StrictMode strict_mode() const { return strict_mode_; }
+ LanguageMode language_mode() const { return language_mode_; }
// The variable corresponding the 'this' value.
Variable* receiver() { return receiver_; }
bool asm_module_;
// This scope's outer context is an asm module.
bool asm_function_;
- // The strict mode of this scope.
- StrictMode strict_mode_;
+ // The language mode of this scope.
+ LanguageMode language_mode_;
// Source positions.
int start_position_;
int end_position_;
return token_type[tok] == 'K';
}
- static bool IsIdentifier(Value tok, StrictMode strict_mode,
+ static bool IsIdentifier(Value tok, LanguageMode language_mode,
bool is_generator) {
switch (tok) {
case IDENTIFIER:
case FUTURE_STRICT_RESERVED_WORD:
case LET:
case STATIC:
- return strict_mode == SLOPPY;
+ return is_sloppy(language_mode);
case YIELD:
- return !is_generator && strict_mode == SLOPPY;
+ return !is_generator && is_sloppy(language_mode);
default:
return false;
}
// Sloppy mode functions and builtins need to replace the receiver with the
// global proxy when called as functions (without an explicit receiver
// object).
- if (info->strict_mode() == SLOPPY && !info->is_native()) {
+ if (is_sloppy(info->language_mode()) && !info->is_native()) {
Label ok;
// +1 for return address.
StackArgumentsAccessor args(rsp, info->scope()->num_parameters());
// The stub will rewrite receiver and parameter count if the previous
// stack frame was an arguments adapter frame.
ArgumentsAccessStub::Type type;
- if (strict_mode() == STRICT) {
+ if (is_strict(language_mode())) {
type = ArgumentsAccessStub::NEW_STRICT;
} else if (function()->has_duplicate_parameters()) {
type = ArgumentsAccessStub::NEW_SLOPPY_SLOW;
!pretenure &&
scope()->is_function_scope() &&
info->num_literals() == 0) {
- FastNewClosureStub stub(isolate(), info->strict_mode(), info->kind());
+ FastNewClosureStub stub(isolate(), info->language_mode(), info->kind());
__ Move(rbx, info);
__ CallStub(&stub);
} else {
VisitForStackValue(value);
if (property->emit_store()) {
EmitSetHomeObjectIfNeeded(value, 2);
- __ Push(Smi::FromInt(SLOPPY)); // Strict mode
+ __ Push(Smi::FromInt(SLOPPY)); // Language mode
__ CallRuntime(Runtime::kSetProperty, 4);
} else {
__ Drop(3);
__ Pop(StoreDescriptor::ReceiverRegister());
__ Pop(StoreDescriptor::ValueRegister()); // Restore value.
Handle<Code> ic =
- CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code();
+ CodeFactory::KeyedStoreIC(isolate(), language_mode()).code();
CallIC(ic);
break;
}
__ Push(rax); // Value.
__ Push(rsi); // Context.
__ Push(var->name());
- __ Push(Smi::FromInt(strict_mode()));
+ __ Push(Smi::FromInt(language_mode()));
__ CallRuntime(Runtime::kStoreLookupSlot, 4);
} else {
// Assignment to var or initializing assignment to let/const in harmony
}
EmitStoreToStackLocalOrContextSlot(var, location);
}
- } else if (IsSignallingAssignmentToConst(var, op, strict_mode())) {
+ } else if (IsSignallingAssignmentToConst(var, op, language_mode())) {
__ CallRuntime(Runtime::kThrowConstAssignError, 0);
}
}
__ Push(key->value());
__ Push(rax);
- __ CallRuntime((strict_mode() == STRICT ? Runtime::kStoreToSuper_Strict
- : Runtime::kStoreToSuper_Sloppy),
+ __ CallRuntime((is_strict(language_mode()) ? Runtime::kStoreToSuper_Strict
+ : Runtime::kStoreToSuper_Sloppy),
4);
}
DCHECK(prop != NULL);
__ Push(rax);
- __ CallRuntime((strict_mode() == STRICT ? Runtime::kStoreKeyedToSuper_Strict
- : Runtime::kStoreKeyedToSuper_Sloppy),
- 4);
+ __ CallRuntime(
+ (is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict
+ : Runtime::kStoreKeyedToSuper_Sloppy),
+ 4);
}
DCHECK(StoreDescriptor::ValueRegister().is(rax));
// Record source code position before IC call.
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());
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
__ Push(args.GetReceiverOperand());
// Push the language mode.
- __ Push(Smi::FromInt(strict_mode()));
+ __ Push(Smi::FromInt(language_mode()));
// Push the start position of the scope the calls resides in.
__ Push(Smi::FromInt(scope()->start_position()));
if (property != NULL) {
VisitForStackValue(property->obj());
VisitForStackValue(property->key());
- __ Push(Smi::FromInt(strict_mode()));
+ __ Push(Smi::FromInt(language_mode()));
__ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
context()->Plug(rax);
} else if (proxy != NULL) {
Variable* var = proxy->var();
// Delete of an unqualified identifier is disallowed in strict mode
// but "delete this" is allowed.
- DCHECK(strict_mode() == SLOPPY || var->is_this());
+ DCHECK(is_sloppy(language_mode()) || var->is_this());
if (var->IsUnallocated()) {
__ Push(GlobalObjectOperand());
__ Push(var->name());
__ Pop(StoreDescriptor::NameRegister());
__ Pop(StoreDescriptor::ReceiverRegister());
Handle<Code> ic =
- CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code();
+ CodeFactory::KeyedStoreIC(isolate(), language_mode()).code();
CallIC(ic, expr->CountStoreFeedbackId());
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
if (expr->is_postfix()) {
// Sloppy mode functions need to replace the receiver with the global proxy
// when called as functions (without an explicit receiver object).
- if (info_->this_has_uses() &&
- info_->strict_mode() == SLOPPY &&
+ if (info_->this_has_uses() && is_sloppy(info_->language_mode()) &&
!info_->is_native()) {
Label ok;
StackArgumentsAccessor args(rsp, scope()->num_parameters());
DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister()));
__ Move(StoreDescriptor::NameRegister(), instr->hydrogen()->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);
}
DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister()));
Handle<Code> ic =
- CodeFactory::KeyedStoreIC(isolate(), instr->strict_mode()).code();
+ CodeFactory::KeyedStoreIC(isolate(), instr->language_mode()).code();
CallCode(ic, RelocInfo::CODE_TARGET, instr);
}
// space for nested functions that don't need literals cloning.
bool pretenure = instr->hydrogen()->pretenure();
if (!pretenure && instr->hydrogen()->has_no_literals()) {
- FastNewClosureStub stub(isolate(), instr->hydrogen()->strict_mode(),
+ FastNewClosureStub stub(isolate(), instr->hydrogen()->language_mode(),
instr->hydrogen()->kind());
__ Move(rbx, instr->hydrogen()->shared_info());
CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
#undef DECLARE_DO
private:
- StrictMode strict_mode() const { return info()->strict_mode(); }
+ LanguageMode language_mode() const { return info()->language_mode(); }
LPlatformChunk* chunk() const { return chunk_; }
Scope* scope() const { return scope_; }
void PrintDataTo(StringStream* stream) OVERRIDE;
Handle<Object> name() const { return hydrogen()->name(); }
- StrictMode strict_mode() { return hydrogen()->strict_mode(); }
+ LanguageMode language_mode() { return hydrogen()->language_mode(); }
};
void PrintDataTo(StringStream* stream) OVERRIDE;
- StrictMode strict_mode() { return hydrogen()->strict_mode(); }
+ LanguageMode language_mode() { return hydrogen()->language_mode(); }
};
const char* inner_source;
const char* outer_suffix;
i::ScopeType scope_type;
- i::StrictMode strict_mode;
+ i::LanguageMode language_mode;
};
const SourceData source_data[] = {
parser.set_allow_harmony_scoping(true);
parser.set_allow_harmony_arrow_functions(true);
info.MarkAsGlobal();
- info.SetStrictMode(source_data[i].strict_mode);
+ info.SetLanguageMode(source_data[i].language_mode);
parser.Parse();
CHECK(info.function() != NULL);
class JSStorePropertyOperatorTest
: public TestWithZone,
- public ::testing::WithParamInterface<StrictMode> {};
+ public ::testing::WithParamInterface<LanguageMode> {};
TEST_P(JSStorePropertyOperatorTest, InstancesAreGloballyShared) {
- const StrictMode mode = GetParam();
+ const LanguageMode mode = GetParam();
JSOperatorBuilder javascript1(zone());
JSOperatorBuilder javascript2(zone());
EXPECT_EQ(javascript1.StoreProperty(mode), javascript2.StoreProperty(mode));
TEST_P(JSStorePropertyOperatorTest, NumberOfInputsAndOutputs) {
JSOperatorBuilder javascript(zone());
- const StrictMode mode = GetParam();
+ const LanguageMode mode = GetParam();
const Operator* op = javascript.StoreProperty(mode);
// TODO(jarin): Get rid of this hack.
TEST_P(JSStorePropertyOperatorTest, OpcodeIsCorrect) {
JSOperatorBuilder javascript(zone());
- const StrictMode mode = GetParam();
+ const LanguageMode mode = GetParam();
const Operator* op = javascript.StoreProperty(mode);
EXPECT_EQ(IrOpcode::kJSStoreProperty, op->opcode());
}
TEST_P(JSStorePropertyOperatorTest, OpParameter) {
JSOperatorBuilder javascript(zone());
- const StrictMode mode = GetParam();
+ const LanguageMode mode = GetParam();
const Operator* op = javascript.StoreProperty(mode);
- EXPECT_EQ(mode, OpParameter<StrictMode>(op));
+ EXPECT_EQ(mode, OpParameter<LanguageMode>(op));
}
TEST_P(JSStorePropertyOperatorTest, Properties) {
JSOperatorBuilder javascript(zone());
- const StrictMode mode = GetParam();
+ const LanguageMode mode = GetParam();
const Operator* op = javascript.StoreProperty(mode);
EXPECT_EQ(Operator::kNoProperties, op->properties());
}
Type::Number(), Type::String(), Type::Object()};
-const StrictMode kStrictModes[] = {SLOPPY, STRICT};
+STATIC_ASSERT(LANGUAGE_END == 2);
+const LanguageMode kLanguageModes[] = {SLOPPY, STRICT};
} // namespace
Handle<JSArrayBuffer> buffer =
NewArrayBuffer(backing_store, sizeof(backing_store));
TRACED_FOREACH(ExternalArrayType, type, kExternalArrayTypes) {
- TRACED_FOREACH(StrictMode, strict_mode, kStrictModes) {
+ TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
Handle<JSTypedArray> array =
factory()->NewJSTypedArray(type, buffer, 0, kLength);
int const element_size = static_cast<int>(array->element_size());
Node* context = UndefinedConstant();
Node* effect = graph()->start();
Node* control = graph()->start();
- Node* node = graph()->NewNode(javascript()->StoreProperty(strict_mode),
+ Node* node = graph()->NewNode(javascript()->StoreProperty(language_mode),
base, key, value, context);
if (FLAG_turbo_deoptimization) {
node->AppendInput(zone(), UndefinedConstant());
Handle<JSArrayBuffer> buffer =
NewArrayBuffer(backing_store, sizeof(backing_store));
TRACED_FOREACH(ExternalArrayType, type, kExternalArrayTypes) {
- TRACED_FOREACH(StrictMode, strict_mode, kStrictModes) {
+ TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
Handle<JSTypedArray> array =
factory()->NewJSTypedArray(type, buffer, 0, kLength);
int const element_size = static_cast<int>(array->element_size());
Node* context = UndefinedConstant();
Node* effect = graph()->start();
Node* control = graph()->start();
- Node* node = graph()->NewNode(javascript()->StoreProperty(strict_mode),
+ Node* node = graph()->NewNode(javascript()->StoreProperty(language_mode),
base, key, value, context);
if (FLAG_turbo_deoptimization) {
node->AppendInput(zone(), UndefinedConstant());
Handle<JSArrayBuffer> buffer =
NewArrayBuffer(backing_store, sizeof(backing_store));
TRACED_FOREACH(ExternalArrayType, type, kExternalArrayTypes) {
- TRACED_FOREACH(StrictMode, strict_mode, kStrictModes) {
+ TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
Handle<JSTypedArray> array =
factory()->NewJSTypedArray(type, buffer, 0, kLength);
ElementAccess access = AccessBuilder::ForTypedArrayElement(type, true);
Node* context = UndefinedConstant();
Node* effect = graph()->start();
Node* control = graph()->start();
- Node* node = graph()->NewNode(javascript()->StoreProperty(strict_mode),
+ Node* node = graph()->NewNode(javascript()->StoreProperty(language_mode),
base, key, value, context);
if (FLAG_turbo_deoptimization) {
node->AppendInput(zone(), UndefinedConstant());