From 5cd84502bf1aadd42b3ccc90746f8bd79402d3b3 Mon Sep 17 00:00:00 2001 From: rossberg Date: Tue, 10 Feb 2015 11:12:51 -0800 Subject: [PATCH] [strong] Introduce --use-strong flag R=marja@chromium.org BUG= Review URL: https://codereview.chromium.org/907403002 Cr-Commit-Position: refs/heads/master@{#26556} --- src/compiler.cc | 18 ++++++++++-------- src/flag-definitions.h | 6 +++++- src/objects.cc | 8 ++++---- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/compiler.cc b/src/compiler.cc index 12437f8..8961deb 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -1358,10 +1358,11 @@ Handle Compiler::CompileScript( compile_options == ScriptCompiler::kProduceCodeCache) { info.PrepareForSerializing(); } - if (FLAG_use_strict) { - info.SetLanguageMode( - static_cast(info.language_mode() | STRICT_BIT)); - } + + LanguageMode language_mode = + construct_language_mode(FLAG_use_strict, FLAG_use_strong); + info.SetLanguageMode( + static_cast(info.language_mode() | language_mode)); result = CompileToplevel(&info); if (extension == NULL && !result.is_null() && !result->dont_cache()) { @@ -1392,10 +1393,11 @@ Handle Compiler::CompileStreamedScript( isolate->counters()->total_load_size()->Increment(source_length); isolate->counters()->total_compile_size()->Increment(source_length); - if (FLAG_use_strict) { - info->SetLanguageMode( - static_cast(info->language_mode() | STRICT_BIT)); - } + LanguageMode language_mode = + construct_language_mode(FLAG_use_strict, FLAG_use_strong); + info->SetLanguageMode( + static_cast(info->language_mode() | language_mode)); + // 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); diff --git a/src/flag-definitions.h b/src/flag-definitions.h index 40d93f6..47600d5 100644 --- a/src/flag-definitions.h +++ b/src/flag-definitions.h @@ -169,6 +169,11 @@ struct MaybeBoolFlag { // Flags for language modes and experimental language features. DEFINE_BOOL(use_strict, false, "enforce strict mode") +DEFINE_BOOL(use_strong, false, "enforce strong mode") +DEFINE_IMPLICATION(use_strong, use_strict) + +DEFINE_BOOL(strong_mode, false, "experimental strong language mode") +DEFINE_IMPLICATION(use_strong, strong_mode) DEFINE_BOOL(es_staging, false, "enable all completed harmony features") DEFINE_BOOL(harmony, false, "enable all completed harmony features") @@ -261,7 +266,6 @@ DEFINE_BOOL(smi_binop, true, "support smi representation in binary operations") DEFINE_BOOL(vector_ics, false, "support vector-based ics") DEFINE_BOOL(experimental_classes, false, "experimental new semantics for super() calls") -DEFINE_BOOL(strong_mode, false, "experimental strong language mode") DEFINE_IMPLICATION(experimental_classes, harmony_classes) DEFINE_IMPLICATION(experimental_classes, harmony_object_literals) diff --git a/src/objects.cc b/src/objects.cc index e8bb005..7e85e59 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -15292,8 +15292,8 @@ Handle CompilationCacheTable::Lookup(Handle src, Handle context) { Isolate* isolate = GetIsolate(); Handle shared(context->closure()->shared()); - StringSharedKey key(src, shared, FLAG_use_strict ? STRICT : SLOPPY, - RelocInfo::kNoPosition); + LanguageMode mode = construct_language_mode(FLAG_use_strict, FLAG_use_strong); + StringSharedKey key(src, shared, mode, RelocInfo::kNoPosition); int entry = FindEntry(&key); if (entry == kNotFound) return isolate->factory()->undefined_value(); int index = EntryToIndex(entry); @@ -15333,8 +15333,8 @@ Handle CompilationCacheTable::Put( Handle context, Handle value) { Isolate* isolate = cache->GetIsolate(); Handle shared(context->closure()->shared()); - StringSharedKey key(src, shared, FLAG_use_strict ? STRICT : SLOPPY, - RelocInfo::kNoPosition); + LanguageMode mode = construct_language_mode(FLAG_use_strict, FLAG_use_strong); + StringSharedKey key(src, shared, mode, RelocInfo::kNoPosition); { Handle k = key.AsHandle(isolate); DisallowHeapAllocation no_allocation_scope; -- 2.7.4