[strong] Introduce --use-strong flag
authorrossberg <rossberg@chromium.org>
Tue, 10 Feb 2015 19:12:51 +0000 (11:12 -0800)
committerCommit bot <commit-bot@chromium.org>
Tue, 10 Feb 2015 19:13:01 +0000 (19:13 +0000)
R=marja@chromium.org
BUG=

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

Cr-Commit-Position: refs/heads/master@{#26556}

src/compiler.cc
src/flag-definitions.h
src/objects.cc

index 12437f8..8961deb 100644 (file)
@@ -1358,10 +1358,11 @@ Handle<SharedFunctionInfo> Compiler::CompileScript(
         compile_options == ScriptCompiler::kProduceCodeCache) {
       info.PrepareForSerializing();
     }
-    if (FLAG_use_strict) {
-      info.SetLanguageMode(
-          static_cast<LanguageMode>(info.language_mode() | STRICT_BIT));
-    }
+
+    LanguageMode language_mode =
+        construct_language_mode(FLAG_use_strict, FLAG_use_strong);
+    info.SetLanguageMode(
+        static_cast<LanguageMode>(info.language_mode() | language_mode));
 
     result = CompileToplevel(&info);
     if (extension == NULL && !result.is_null() && !result->dont_cache()) {
@@ -1392,10 +1393,11 @@ Handle<SharedFunctionInfo> 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<LanguageMode>(info->language_mode() | STRICT_BIT));
-  }
+  LanguageMode language_mode =
+      construct_language_mode(FLAG_use_strict, FLAG_use_strong);
+  info->SetLanguageMode(
+      static_cast<LanguageMode>(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);
index 40d93f6..47600d5 100644 (file)
@@ -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)
 
index e8bb005..7e85e59 100644 (file)
@@ -15292,8 +15292,8 @@ Handle<Object> CompilationCacheTable::Lookup(Handle<String> src,
                                              Handle<Context> context) {
   Isolate* isolate = GetIsolate();
   Handle<SharedFunctionInfo> 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> CompilationCacheTable::Put(
     Handle<Context> context, Handle<Object> value) {
   Isolate* isolate = cache->GetIsolate();
   Handle<SharedFunctionInfo> 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<Object> k = key.AsHandle(isolate);
     DisallowHeapAllocation no_allocation_scope;