Make writing of frame translation platform independent.
authorjarin <jarin@chromium.org>
Thu, 11 Jun 2015 06:09:07 +0000 (23:09 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 11 Jun 2015 06:09:13 +0000 (06:09 +0000)
BUG=
R=bmeurer@chromium.org

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

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

18 files changed:
src/arm/lithium-codegen-arm.cc
src/arm/lithium-codegen-arm.h
src/arm64/lithium-codegen-arm64.cc
src/arm64/lithium-codegen-arm64.h
src/ia32/lithium-codegen-ia32.cc
src/ia32/lithium-codegen-ia32.h
src/lithium-codegen.cc
src/lithium-codegen.h
src/mips/lithium-codegen-mips.cc
src/mips/lithium-codegen-mips.h
src/mips64/lithium-codegen-mips64.cc
src/mips64/lithium-codegen-mips64.h
src/ppc/lithium-codegen-ppc.cc
src/ppc/lithium-codegen-ppc.h
src/x64/lithium-codegen-x64.cc
src/x64/lithium-codegen-x64.h
src/x87/lithium-codegen-x87.cc
src/x87/lithium-codegen-x87.h

index 6cf98f8422c3cc9fd9ac4fcbeb9178ea936fdefc..8f6cdd3cf6975e63b925e50c4a1453568a113894 100644 (file)
@@ -596,85 +596,9 @@ void LCodeGen::WriteTranslation(LEnvironment* environment,
 
   // The translation includes one command per value in the environment.
   int translation_size = environment->translation_size();
-  // The output frame height does not include the parameters.
-  int height = translation_size - environment->parameter_count();
 
   WriteTranslation(environment->outer(), translation);
-
-  switch (environment->frame_type()) {
-    case JS_FUNCTION: {
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginJSFrame(environment->ast_id(), shared_id, height);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case JS_CONSTRUCT: {
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginConstructStubFrame(shared_id, translation_size);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case JS_GETTER: {
-      DCHECK(translation_size == 1);
-      DCHECK(height == 0);
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginGetterStubFrame(shared_id);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case JS_SETTER: {
-      DCHECK(translation_size == 2);
-      DCHECK(height == 0);
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginSetterStubFrame(shared_id);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case ARGUMENTS_ADAPTOR: {
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginArgumentsAdaptorFrame(shared_id, translation_size);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case STUB:
-      translation->BeginCompiledStubFrame(translation_size);
-      break;
-  }
+  WriteTranslationFrame(environment, translation);
 
   int object_index = 0;
   int dematerialized_index = 0;
@@ -1002,16 +926,6 @@ void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) {
 }
 
 
-int LCodeGen::DefineDeoptimizationLiteral(Handle<Object> literal) {
-  int result = deoptimization_literals_.length();
-  for (int i = 0; i < deoptimization_literals_.length(); ++i) {
-    if (deoptimization_literals_[i].is_identical_to(literal)) return i;
-  }
-  deoptimization_literals_.Add(literal, zone());
-  return result;
-}
-
-
 void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() {
   DCHECK_EQ(0, deoptimization_literals_.length());
   for (auto function : chunk()->inlined_functions()) {
index add08a1b498292a896d70c8cccfe66b749f27fb8..75b0fc0e4a6c05bc3068104b9cdd850f241e5055 100644 (file)
@@ -27,7 +27,6 @@ class LCodeGen: public LCodeGenBase {
       : LCodeGenBase(chunk, assembler, info),
         deoptimizations_(4, info->zone()),
         jump_table_(4, info->zone()),
-        deoptimization_literals_(8, info->zone()),
         inlined_function_count_(0),
         scope_(info->scope()),
         translations_(info->zone()),
@@ -242,7 +241,6 @@ class LCodeGen: public LCodeGenBase {
                         int* object_index_pointer,
                         int* dematerialized_index_pointer);
   void PopulateDeoptimizationData(Handle<Code> code);
-  int DefineDeoptimizationLiteral(Handle<Object> literal);
 
   void PopulateDeoptimizationLiteralsWithInlinedFunctions();
 
@@ -328,7 +326,6 @@ class LCodeGen: public LCodeGenBase {
 
   ZoneList<LEnvironment*> deoptimizations_;
   ZoneList<Deoptimizer::JumpTableEntry> jump_table_;
-  ZoneList<Handle<Object> > deoptimization_literals_;
   int inlined_function_count_;
   Scope* const scope_;
   TranslationBuffer translations_;
index cf6816d9abd46cedf81746e4241d92160bcdf3ef..ec6e3c7038c3d29ecbeec651ceb5d2848a261260 100644 (file)
@@ -224,85 +224,9 @@ void LCodeGen::WriteTranslation(LEnvironment* environment,
 
   // The translation includes one command per value in the environment.
   int translation_size = environment->translation_size();
-  // The output frame height does not include the parameters.
-  int height = translation_size - environment->parameter_count();
 
   WriteTranslation(environment->outer(), translation);
-
-  switch (environment->frame_type()) {
-    case JS_FUNCTION: {
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginJSFrame(environment->ast_id(), shared_id, height);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case JS_CONSTRUCT: {
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginConstructStubFrame(shared_id, translation_size);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case JS_GETTER: {
-      DCHECK(translation_size == 1);
-      DCHECK(height == 0);
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginGetterStubFrame(shared_id);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case JS_SETTER: {
-      DCHECK(translation_size == 2);
-      DCHECK(height == 0);
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginSetterStubFrame(shared_id);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case ARGUMENTS_ADAPTOR: {
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginArgumentsAdaptorFrame(shared_id, translation_size);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case STUB:
-      translation->BeginCompiledStubFrame(translation_size);
-      break;
-  }
+  WriteTranslationFrame(environment, translation);
 
   int object_index = 0;
   int dematerialized_index = 0;
@@ -383,16 +307,6 @@ void LCodeGen::AddToTranslation(LEnvironment* environment,
 }
 
 
-int LCodeGen::DefineDeoptimizationLiteral(Handle<Object> literal) {
-  int result = deoptimization_literals_.length();
-  for (int i = 0; i < deoptimization_literals_.length(); ++i) {
-    if (deoptimization_literals_[i].is_identical_to(literal)) return i;
-  }
-  deoptimization_literals_.Add(literal, zone());
-  return result;
-}
-
-
 void LCodeGen::RegisterEnvironmentForDeoptimization(LEnvironment* environment,
                                                     Safepoint::DeoptMode mode) {
   environment->set_has_been_used();
index 76ad8d4e2cfb8d3f1ba4069788643e4710429ecf..c9ad76c7428787289e1d6b5ede73836041e06361 100644 (file)
@@ -28,7 +28,6 @@ class LCodeGen: public LCodeGenBase {
       : LCodeGenBase(chunk, assembler, info),
         deoptimizations_(4, info->zone()),
         jump_table_(4, info->zone()),
-        deoptimization_literals_(8, info->zone()),
         inlined_function_count_(0),
         scope_(info->scope()),
         translations_(info->zone()),
@@ -198,7 +197,6 @@ class LCodeGen: public LCodeGenBase {
   Condition EmitIsString(Register input, Register temp1, Label* is_not_string,
                          SmiCheck check_needed);
 
-  int DefineDeoptimizationLiteral(Handle<Object> literal);
   void PopulateDeoptimizationData(Handle<Code> code);
   void PopulateDeoptimizationLiteralsWithInlinedFunctions();
 
@@ -342,7 +340,6 @@ class LCodeGen: public LCodeGenBase {
 
   ZoneList<LEnvironment*> deoptimizations_;
   ZoneList<Deoptimizer::JumpTableEntry*> jump_table_;
-  ZoneList<Handle<Object> > deoptimization_literals_;
   int inlined_function_count_;
   Scope* const scope_;
   TranslationBuffer translations_;
index 3e5a2fe021b6294aad403d24497f88712f71c5ea..ba601db35dd22f033c7737d4276abdac5478dec2 100644 (file)
@@ -618,85 +618,9 @@ void LCodeGen::WriteTranslation(LEnvironment* environment,
 
   // The translation includes one command per value in the environment.
   int translation_size = environment->translation_size();
-  // The output frame height does not include the parameters.
-  int height = translation_size - environment->parameter_count();
 
   WriteTranslation(environment->outer(), translation);
-
-  switch (environment->frame_type()) {
-    case JS_FUNCTION: {
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginJSFrame(environment->ast_id(), shared_id, height);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case JS_CONSTRUCT: {
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginConstructStubFrame(shared_id, translation_size);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case JS_GETTER: {
-      DCHECK(translation_size == 1);
-      DCHECK(height == 0);
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginGetterStubFrame(shared_id);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case JS_SETTER: {
-      DCHECK(translation_size == 2);
-      DCHECK(height == 0);
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginSetterStubFrame(shared_id);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case ARGUMENTS_ADAPTOR: {
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginArgumentsAdaptorFrame(shared_id, translation_size);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case STUB:
-      translation->BeginCompiledStubFrame(translation_size);
-      break;
-  }
+  WriteTranslationFrame(environment, translation);
 
   int object_index = 0;
   int dematerialized_index = 0;
@@ -1006,16 +930,6 @@ void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) {
 }
 
 
-int LCodeGen::DefineDeoptimizationLiteral(Handle<Object> literal) {
-  int result = deoptimization_literals_.length();
-  for (int i = 0; i < deoptimization_literals_.length(); ++i) {
-    if (deoptimization_literals_[i].is_identical_to(literal)) return i;
-  }
-  deoptimization_literals_.Add(literal, zone());
-  return result;
-}
-
-
 void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() {
   DCHECK_EQ(0, deoptimization_literals_.length());
   for (auto function : chunk()->inlined_functions()) {
index 256fa81d41533012b15ddcfff72138f6c5ed1cb0..e56168fdb06290c7f77cf19f2c1efa733c0d3f7a 100644 (file)
@@ -29,7 +29,6 @@ class LCodeGen: public LCodeGenBase {
       : LCodeGenBase(chunk, assembler, info),
         deoptimizations_(4, info->zone()),
         jump_table_(4, info->zone()),
-        deoptimization_literals_(8, info->zone()),
         inlined_function_count_(0),
         scope_(info->scope()),
         translations_(info->zone()),
@@ -221,7 +220,6 @@ class LCodeGen: public LCodeGenBase {
                         int* object_index_pointer,
                         int* dematerialized_index_pointer);
   void PopulateDeoptimizationData(Handle<Code> code);
-  int DefineDeoptimizationLiteral(Handle<Object> literal);
 
   void PopulateDeoptimizationLiteralsWithInlinedFunctions();
 
@@ -329,7 +327,6 @@ class LCodeGen: public LCodeGenBase {
 
   ZoneList<LEnvironment*> deoptimizations_;
   ZoneList<Deoptimizer::JumpTableEntry> jump_table_;
-  ZoneList<Handle<Object> > deoptimization_literals_;
   int inlined_function_count_;
   Scope* const scope_;
   TranslationBuffer translations_;
index 6fac0b9e2c8a1f0d5d20fb607dc6994e87c15865..24c1301dc514b59dcfa5f4c7daa8bf38ff31122c 100644 (file)
@@ -45,8 +45,7 @@ HGraph* LCodeGenBase::graph() const {
 }
 
 
-LCodeGenBase::LCodeGenBase(LChunk* chunk,
-                           MacroAssembler* assembler,
+LCodeGenBase::LCodeGenBase(LChunk* chunk, MacroAssembler* assembler,
                            CompilationInfo* info)
     : chunk_(static_cast<LPlatformChunk*>(chunk)),
       masm_(assembler),
@@ -56,8 +55,8 @@ LCodeGenBase::LCodeGenBase(LChunk* chunk,
       current_block_(-1),
       current_instruction_(-1),
       instructions_(chunk->instructions()),
-      last_lazy_deopt_pc_(0) {
-}
+      deoptimization_literals_(8, info->zone()),
+      last_lazy_deopt_pc_(0) {}
 
 
 bool LCodeGenBase::GenerateBody() {
@@ -190,6 +189,99 @@ void LCodeGenBase::AddStabilityDependency(Handle<Map> map) {
 }
 
 
+int LCodeGenBase::DefineDeoptimizationLiteral(Handle<Object> literal) {
+  int result = deoptimization_literals_.length();
+  for (int i = 0; i < deoptimization_literals_.length(); ++i) {
+    if (deoptimization_literals_[i].is_identical_to(literal)) return i;
+  }
+  deoptimization_literals_.Add(literal, zone());
+  return result;
+}
+
+
+void LCodeGenBase::WriteTranslationFrame(LEnvironment* environment,
+                                         Translation* translation) {
+  int translation_size = environment->translation_size();
+  // The output frame height does not include the parameters.
+  int height = translation_size - environment->parameter_count();
+
+  switch (environment->frame_type()) {
+    case JS_FUNCTION: {
+      int shared_id = DefineDeoptimizationLiteral(
+          environment->entry() ? environment->entry()->shared()
+                               : info()->shared_info());
+      translation->BeginJSFrame(environment->ast_id(), shared_id, height);
+      if (info()->closure().is_identical_to(environment->closure())) {
+        translation->StoreJSFrameFunction();
+      } else {
+        int closure_id = DefineDeoptimizationLiteral(environment->closure());
+        translation->StoreLiteral(closure_id);
+      }
+      break;
+    }
+    case JS_CONSTRUCT: {
+      int shared_id = DefineDeoptimizationLiteral(
+          environment->entry() ? environment->entry()->shared()
+                               : info()->shared_info());
+      translation->BeginConstructStubFrame(shared_id, translation_size);
+      if (info()->closure().is_identical_to(environment->closure())) {
+        translation->StoreJSFrameFunction();
+      } else {
+        int closure_id = DefineDeoptimizationLiteral(environment->closure());
+        translation->StoreLiteral(closure_id);
+      }
+      break;
+    }
+    case JS_GETTER: {
+      DCHECK(translation_size == 1);
+      DCHECK(height == 0);
+      int shared_id = DefineDeoptimizationLiteral(
+          environment->entry() ? environment->entry()->shared()
+                               : info()->shared_info());
+      translation->BeginGetterStubFrame(shared_id);
+      if (info()->closure().is_identical_to(environment->closure())) {
+        translation->StoreJSFrameFunction();
+      } else {
+        int closure_id = DefineDeoptimizationLiteral(environment->closure());
+        translation->StoreLiteral(closure_id);
+      }
+      break;
+    }
+    case JS_SETTER: {
+      DCHECK(translation_size == 2);
+      DCHECK(height == 0);
+      int shared_id = DefineDeoptimizationLiteral(
+          environment->entry() ? environment->entry()->shared()
+                               : info()->shared_info());
+      translation->BeginSetterStubFrame(shared_id);
+      if (info()->closure().is_identical_to(environment->closure())) {
+        translation->StoreJSFrameFunction();
+      } else {
+        int closure_id = DefineDeoptimizationLiteral(environment->closure());
+        translation->StoreLiteral(closure_id);
+      }
+      break;
+    }
+    case ARGUMENTS_ADAPTOR: {
+      int shared_id = DefineDeoptimizationLiteral(
+          environment->entry() ? environment->entry()->shared()
+                               : info()->shared_info());
+      translation->BeginArgumentsAdaptorFrame(shared_id, translation_size);
+      if (info()->closure().is_identical_to(environment->closure())) {
+        translation->StoreJSFrameFunction();
+      } else {
+        int closure_id = DefineDeoptimizationLiteral(environment->closure());
+        translation->StoreLiteral(closure_id);
+      }
+      break;
+    }
+    case STUB:
+      translation->BeginCompiledStubFrame(translation_size);
+      break;
+  }
+}
+
+
 Deoptimizer::DeoptInfo LCodeGenBase::MakeDeoptInfo(
     LInstruction* instr, Deoptimizer::DeoptReason deopt_reason) {
   Deoptimizer::DeoptInfo deopt_info(instr->hydrogen_value()->position(),
index 80afbaf2359d633e57d8ff518d77a71589e47e7f..fddc1b259935968d53796f71e0c766e7898dee0e 100644 (file)
@@ -14,6 +14,7 @@
 namespace v8 {
 namespace internal {
 
+class LEnvironment;
 class LInstruction;
 class LPlatformChunk;
 
@@ -50,6 +51,10 @@ class LCodeGenBase BASE_EMBEDDED {
 
   void RegisterWeakObjectsInOptimizedCode(Handle<Code> code);
 
+  void WriteTranslationFrame(LEnvironment* environment,
+                             Translation* translation);
+  int DefineDeoptimizationLiteral(Handle<Object> literal);
+
   // Check that an environment assigned via AssignEnvironment is actually being
   // used. Redundant assignments keep things alive longer than necessary, and
   // consequently lead to worse code, so it's important to minimize this.
@@ -71,6 +76,7 @@ class LCodeGenBase BASE_EMBEDDED {
   int current_block_;
   int current_instruction_;
   const ZoneList<LInstruction*>* instructions_;
+  ZoneList<Handle<Object> > deoptimization_literals_;
   int last_lazy_deopt_pc_;
 
   bool is_unused() const { return status_ == UNUSED; }
index 8aa2160a5c7ea25407ac21436078bfe8a366483f..39a5477f525531e9d0166ddebae8026c41e8186f 100644 (file)
@@ -594,85 +594,9 @@ void LCodeGen::WriteTranslation(LEnvironment* environment,
 
   // The translation includes one command per value in the environment.
   int translation_size = environment->translation_size();
-  // The output frame height does not include the parameters.
-  int height = translation_size - environment->parameter_count();
 
   WriteTranslation(environment->outer(), translation);
-
-  switch (environment->frame_type()) {
-    case JS_FUNCTION: {
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginJSFrame(environment->ast_id(), shared_id, height);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case JS_CONSTRUCT: {
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginConstructStubFrame(shared_id, translation_size);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case JS_GETTER: {
-      DCHECK(translation_size == 1);
-      DCHECK(height == 0);
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginGetterStubFrame(shared_id);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case JS_SETTER: {
-      DCHECK(translation_size == 2);
-      DCHECK(height == 0);
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginSetterStubFrame(shared_id);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case ARGUMENTS_ADAPTOR: {
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginArgumentsAdaptorFrame(shared_id, translation_size);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case STUB:
-      translation->BeginCompiledStubFrame(translation_size);
-      break;
-  }
+  WriteTranslationFrame(environment, translation);
 
   int object_index = 0;
   int dematerialized_index = 0;
@@ -969,16 +893,6 @@ void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) {
 }
 
 
-int LCodeGen::DefineDeoptimizationLiteral(Handle<Object> literal) {
-  int result = deoptimization_literals_.length();
-  for (int i = 0; i < deoptimization_literals_.length(); ++i) {
-    if (deoptimization_literals_[i].is_identical_to(literal)) return i;
-  }
-  deoptimization_literals_.Add(literal, zone());
-  return result;
-}
-
-
 void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() {
   DCHECK_EQ(0, deoptimization_literals_.length());
   for (auto function : chunk()->inlined_functions()) {
index a683596568adbf3f5e272fe80709b1797931ac4a..7b68bd75e796e99bad7a0a35da0338f312421408 100644 (file)
@@ -26,7 +26,6 @@ class LCodeGen: public LCodeGenBase {
       : LCodeGenBase(chunk, assembler, info),
         deoptimizations_(4, info->zone()),
         jump_table_(4, info->zone()),
-        deoptimization_literals_(8, info->zone()),
         inlined_function_count_(0),
         scope_(info->scope()),
         translations_(info->zone()),
@@ -240,7 +239,6 @@ class LCodeGen: public LCodeGenBase {
                         int* object_index_pointer,
                         int* dematerialized_index_pointer);
   void PopulateDeoptimizationData(Handle<Code> code);
-  int DefineDeoptimizationLiteral(Handle<Object> literal);
 
   void PopulateDeoptimizationLiteralsWithInlinedFunctions();
 
@@ -359,7 +357,6 @@ class LCodeGen: public LCodeGenBase {
 
   ZoneList<LEnvironment*> deoptimizations_;
   ZoneList<Deoptimizer::JumpTableEntry> jump_table_;
-  ZoneList<Handle<Object> > deoptimization_literals_;
   int inlined_function_count_;
   Scope* const scope_;
   TranslationBuffer translations_;
index cbfc2f8351081d4aa3b2f9f4a8fe743e8c8c165a..c06d80f0a5b0c646d03c309736d45848508f98b0 100644 (file)
@@ -582,85 +582,9 @@ void LCodeGen::WriteTranslation(LEnvironment* environment,
 
   // The translation includes one command per value in the environment.
   int translation_size = environment->translation_size();
-  // The output frame height does not include the parameters.
-  int height = translation_size - environment->parameter_count();
 
   WriteTranslation(environment->outer(), translation);
-
-  switch (environment->frame_type()) {
-    case JS_FUNCTION: {
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginJSFrame(environment->ast_id(), shared_id, height);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case JS_CONSTRUCT: {
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginConstructStubFrame(shared_id, translation_size);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case JS_GETTER: {
-      DCHECK(translation_size == 1);
-      DCHECK(height == 0);
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginGetterStubFrame(shared_id);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case JS_SETTER: {
-      DCHECK(translation_size == 2);
-      DCHECK(height == 0);
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginSetterStubFrame(shared_id);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case ARGUMENTS_ADAPTOR: {
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginArgumentsAdaptorFrame(shared_id, translation_size);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case STUB:
-      translation->BeginCompiledStubFrame(translation_size);
-      break;
-  }
+  WriteTranslationFrame(environment, translation);
 
   int object_index = 0;
   int dematerialized_index = 0;
@@ -958,16 +882,6 @@ void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) {
 }
 
 
-int LCodeGen::DefineDeoptimizationLiteral(Handle<Object> literal) {
-  int result = deoptimization_literals_.length();
-  for (int i = 0; i < deoptimization_literals_.length(); ++i) {
-    if (deoptimization_literals_[i].is_identical_to(literal)) return i;
-  }
-  deoptimization_literals_.Add(literal, zone());
-  return result;
-}
-
-
 void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() {
   DCHECK_EQ(0, deoptimization_literals_.length());
   for (auto function : chunk()->inlined_functions()) {
index a9539a7e6983c2da2a90d3c4f30f421924a2b55c..be08bd49e333cb613a2cd92d41fe7af8aa8c8172 100644 (file)
@@ -26,7 +26,6 @@ class LCodeGen: public LCodeGenBase {
       : LCodeGenBase(chunk, assembler, info),
         deoptimizations_(4, info->zone()),
         jump_table_(4, info->zone()),
-        deoptimization_literals_(8, info->zone()),
         inlined_function_count_(0),
         scope_(info->scope()),
         translations_(info->zone()),
@@ -241,7 +240,6 @@ class LCodeGen: public LCodeGenBase {
                         int* object_index_pointer,
                         int* dematerialized_index_pointer);
   void PopulateDeoptimizationData(Handle<Code> code);
-  int DefineDeoptimizationLiteral(Handle<Object> literal);
 
   void PopulateDeoptimizationLiteralsWithInlinedFunctions();
 
@@ -360,7 +358,6 @@ class LCodeGen: public LCodeGenBase {
 
   ZoneList<LEnvironment*> deoptimizations_;
   ZoneList<Deoptimizer::JumpTableEntry*> jump_table_;
-  ZoneList<Handle<Object> > deoptimization_literals_;
   int inlined_function_count_;
   Scope* const scope_;
   TranslationBuffer translations_;
index c392b100c591de80ce118325ce21a88550339e8b..fea04e36f0b0a2746003f919b0422afa8b2da37f 100644 (file)
@@ -566,85 +566,9 @@ void LCodeGen::WriteTranslation(LEnvironment* environment,
 
   // The translation includes one command per value in the environment.
   int translation_size = environment->translation_size();
-  // The output frame height does not include the parameters.
-  int height = translation_size - environment->parameter_count();
 
   WriteTranslation(environment->outer(), translation);
-
-  switch (environment->frame_type()) {
-    case JS_FUNCTION: {
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginJSFrame(environment->ast_id(), shared_id, height);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case JS_CONSTRUCT: {
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginConstructStubFrame(shared_id, translation_size);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case JS_GETTER: {
-      DCHECK(translation_size == 1);
-      DCHECK(height == 0);
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginGetterStubFrame(shared_id);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case JS_SETTER: {
-      DCHECK(translation_size == 2);
-      DCHECK(height == 0);
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginSetterStubFrame(shared_id);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case ARGUMENTS_ADAPTOR: {
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginArgumentsAdaptorFrame(shared_id, translation_size);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case STUB:
-      translation->BeginCompiledStubFrame(translation_size);
-      break;
-  }
+  WriteTranslationFrame(environment, translation);
 
   int object_index = 0;
   int dematerialized_index = 0;
@@ -932,16 +856,6 @@ void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) {
 }
 
 
-int LCodeGen::DefineDeoptimizationLiteral(Handle<Object> literal) {
-  int result = deoptimization_literals_.length();
-  for (int i = 0; i < deoptimization_literals_.length(); ++i) {
-    if (deoptimization_literals_[i].is_identical_to(literal)) return i;
-  }
-  deoptimization_literals_.Add(literal, zone());
-  return result;
-}
-
-
 void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() {
   DCHECK_EQ(0, deoptimization_literals_.length());
   for (auto function : chunk()->inlined_functions()) {
index 5ebb72e55c10554eab0f6d6087cf402b72ebfd7a..b266e8e58a97335c0bf669d5838d30b802e275d9 100644 (file)
@@ -27,7 +27,6 @@ class LCodeGen : public LCodeGenBase {
       : LCodeGenBase(chunk, assembler, info),
         deoptimizations_(4, info->zone()),
         jump_table_(4, info->zone()),
-        deoptimization_literals_(8, info->zone()),
         inlined_function_count_(0),
         scope_(info->scope()),
         translations_(info->zone()),
@@ -213,7 +212,6 @@ class LCodeGen : public LCodeGenBase {
                         int* object_index_pointer,
                         int* dematerialized_index_pointer);
   void PopulateDeoptimizationData(Handle<Code> code);
-  int DefineDeoptimizationLiteral(Handle<Object> literal);
 
   void PopulateDeoptimizationLiteralsWithInlinedFunctions();
 
@@ -290,7 +288,6 @@ class LCodeGen : public LCodeGenBase {
 
   ZoneList<LEnvironment*> deoptimizations_;
   ZoneList<Deoptimizer::JumpTableEntry> jump_table_;
-  ZoneList<Handle<Object> > deoptimization_literals_;
   int inlined_function_count_;
   Scope* const scope_;
   TranslationBuffer translations_;
index b242bf3b01c5781879afcde185b6b8bc330d374e..331584a30aa6d7b69d66c22c59c5ba7aec193d70 100644 (file)
@@ -537,85 +537,9 @@ void LCodeGen::WriteTranslation(LEnvironment* environment,
 
   // The translation includes one command per value in the environment.
   int translation_size = environment->translation_size();
-  // The output frame height does not include the parameters.
-  int height = translation_size - environment->parameter_count();
 
   WriteTranslation(environment->outer(), translation);
-
-  switch (environment->frame_type()) {
-    case JS_FUNCTION: {
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginJSFrame(environment->ast_id(), shared_id, height);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case JS_CONSTRUCT: {
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginConstructStubFrame(shared_id, translation_size);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case JS_GETTER: {
-      DCHECK(translation_size == 1);
-      DCHECK(height == 0);
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginGetterStubFrame(shared_id);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case JS_SETTER: {
-      DCHECK(translation_size == 2);
-      DCHECK(height == 0);
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginSetterStubFrame(shared_id);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case ARGUMENTS_ADAPTOR: {
-      int shared_id = DefineDeoptimizationLiteral(
-          environment->entry() ? environment->entry()->shared()
-                               : info()->shared_info());
-      translation->BeginArgumentsAdaptorFrame(shared_id, translation_size);
-      if (info()->closure().is_identical_to(environment->closure())) {
-        translation->StoreJSFrameFunction();
-      } else {
-        int closure_id = DefineDeoptimizationLiteral(environment->closure());
-        translation->StoreLiteral(closure_id);
-      }
-      break;
-    }
-    case STUB:
-      translation->BeginCompiledStubFrame(translation_size);
-      break;
-  }
+  WriteTranslationFrame(environment, translation);
 
   int object_index = 0;
   int dematerialized_index = 0;
@@ -930,16 +854,6 @@ void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) {
 }
 
 
-int LCodeGen::DefineDeoptimizationLiteral(Handle<Object> literal) {
-  int result = deoptimization_literals_.length();
-  for (int i = 0; i < deoptimization_literals_.length(); ++i) {
-    if (deoptimization_literals_[i].is_identical_to(literal)) return i;
-  }
-  deoptimization_literals_.Add(literal, zone());
-  return result;
-}
-
-
 void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() {
   DCHECK_EQ(0, deoptimization_literals_.length());
   for (auto function : chunk()->inlined_functions()) {
index 4a0ed7d9ed8b730731a15d88fc5e550e247e79ff..d6682b63a68bb109baed443e9c19b1dddf89e445 100644 (file)
@@ -28,7 +28,6 @@ class LCodeGen: public LCodeGenBase {
       : LCodeGenBase(chunk, assembler, info),
         deoptimizations_(4, info->zone()),
         jump_table_(4, info->zone()),
-        deoptimization_literals_(8, info->zone()),
         inlined_function_count_(0),
         scope_(info->scope()),
         translations_(info->zone()),
@@ -218,7 +217,6 @@ class LCodeGen: public LCodeGenBase {
                         int* object_index_pointer,
                         int* dematerialized_index_pointer);
   void PopulateDeoptimizationData(Handle<Code> code);
-  int DefineDeoptimizationLiteral(Handle<Object> literal);
 
   void PopulateDeoptimizationLiteralsWithInlinedFunctions();
 
@@ -318,7 +316,6 @@ class LCodeGen: public LCodeGenBase {
 
   ZoneList<LEnvironment*> deoptimizations_;
   ZoneList<Deoptimizer::JumpTableEntry> jump_table_;
-  ZoneList<Handle<Object> > deoptimization_literals_;
   int inlined_function_count_;
   Scope* const scope_;
   TranslationBuffer translations_;
index 58925cd1cf4c1398e0e96e866723961c2b176d9c..ef9807fe69256978a2755802ff522d01e2d9d4a0 100644 (file)
@@ -884,41 +884,9 @@ void LCodeGen::WriteTranslation(LEnvironment* environment,
 
   // The translation includes one command per value in the environment.
   int translation_size = environment->translation_size();
-  // The output frame height does not include the parameters.
-  int height = translation_size - environment->parameter_count();
 
   WriteTranslation(environment->outer(), translation);
-  bool has_closure_id = !info()->closure().is_null() &&
-      !info()->closure().is_identical_to(environment->closure());
-  int closure_id = has_closure_id
-      ? DefineDeoptimizationLiteral(environment->closure())
-      : Translation::kSelfLiteralId;
-  switch (environment->frame_type()) {
-    case JS_FUNCTION:
-      translation->BeginJSFrame(environment->ast_id(), closure_id, height);
-      break;
-    case JS_CONSTRUCT:
-      translation->BeginConstructStubFrame(closure_id, translation_size);
-      break;
-    case JS_GETTER:
-      DCHECK(translation_size == 1);
-      DCHECK(height == 0);
-      translation->BeginGetterStubFrame(closure_id);
-      break;
-    case JS_SETTER:
-      DCHECK(translation_size == 2);
-      DCHECK(height == 0);
-      translation->BeginSetterStubFrame(closure_id);
-      break;
-    case ARGUMENTS_ADAPTOR:
-      translation->BeginArgumentsAdaptorFrame(closure_id, translation_size);
-      break;
-    case STUB:
-      translation->BeginCompiledStubFrame(translation_size);
-      break;
-    default:
-      UNREACHABLE();
-  }
+  WriteTranslationFrame(environment, translation);
 
   int object_index = 0;
   int dematerialized_index = 0;
@@ -1251,16 +1219,6 @@ void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) {
 }
 
 
-int LCodeGen::DefineDeoptimizationLiteral(Handle<Object> literal) {
-  int result = deoptimization_literals_.length();
-  for (int i = 0; i < deoptimization_literals_.length(); ++i) {
-    if (deoptimization_literals_[i].is_identical_to(literal)) return i;
-  }
-  deoptimization_literals_.Add(literal, zone());
-  return result;
-}
-
-
 void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() {
   DCHECK_EQ(0, deoptimization_literals_.length());
   for (auto function : chunk()->inlined_functions()) {
index 8104b1b5548b92e46e8b4dbb07d5f3c894c69aa4..4376f756e7b834fbfe078e32dbbfddb18b08e0ae 100644 (file)
@@ -30,7 +30,6 @@ class LCodeGen: public LCodeGenBase {
       : LCodeGenBase(chunk, assembler, info),
         deoptimizations_(4, info->zone()),
         jump_table_(4, info->zone()),
-        deoptimization_literals_(8, info->zone()),
         inlined_function_count_(0),
         scope_(info->scope()),
         translations_(info->zone()),
@@ -248,7 +247,6 @@ class LCodeGen: public LCodeGenBase {
                         int* object_index_pointer,
                         int* dematerialized_index_pointer);
   void PopulateDeoptimizationData(Handle<Code> code);
-  int DefineDeoptimizationLiteral(Handle<Object> literal);
 
   void PopulateDeoptimizationLiteralsWithInlinedFunctions();
 
@@ -363,7 +361,6 @@ class LCodeGen: public LCodeGenBase {
 
   ZoneList<LEnvironment*> deoptimizations_;
   ZoneList<Deoptimizer::JumpTableEntry> jump_table_;
-  ZoneList<Handle<Object> > deoptimization_literals_;
   int inlined_function_count_;
   Scope* const scope_;
   TranslationBuffer translations_;