Revert 15635: Turn ElementsTransitionAndStore stub into a HydrogenCodeStub
authordanno@chromium.org <danno@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 15 Jul 2013 15:23:52 +0000 (15:23 +0000)
committerdanno@chromium.org <danno@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 15 Jul 2013 15:23:52 +0000 (15:23 +0000)
Causes breakage in crypto-(sha1|md5) SunSpider

TBR=bmeurer@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15674 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

12 files changed:
src/arm/code-stubs-arm.cc
src/code-stubs-hydrogen.cc
src/code-stubs.cc
src/code-stubs.h
src/elements-kind.h
src/flag-definitions.h
src/ia32/code-stubs-ia32.cc
src/ic.cc
src/ic.h
src/mips/code-stubs-mips.cc
src/stub-cache.cc
src/x64/code-stubs-x64.cc

index 8f8094f..ff754ec 100644 (file)
@@ -258,17 +258,6 @@ void StoreGlobalStub::InitializeInterfaceDescriptor(
 }
 
 
-void ElementsTransitionAndStoreStub::InitializeInterfaceDescriptor(
-    Isolate* isolate,
-    CodeStubInterfaceDescriptor* descriptor) {
-  static Register registers[] = { r0, r3, r1, r2 };
-  descriptor->register_param_count_ = 4;
-  descriptor->register_params_ = registers;
-  descriptor->deoptimization_handler_ =
-      FUNCTION_ADDR(ElementsTransitionAndStoreIC_Miss);
-}
-
-
 #define __ ACCESS_MASM(masm)
 
 
index d5bb5e7..16f4ac0 100644 (file)
@@ -908,75 +908,4 @@ Handle<Code> StoreGlobalStub::GenerateCode() {
 }
 
 
-template<>
-HValue* CodeStubGraphBuilder<ElementsTransitionAndStoreStub>::BuildCodeStub() {
-  ElementsTransitionAndStoreStub* stub = casted_stub();
-  ElementsKind from_kind = stub->from();
-  ElementsKind to_kind = stub->to();
-
-  HValue* value = GetParameter(0);
-  HValue* target_map = GetParameter(1);
-  HValue* key = GetParameter(2);
-  HValue* object = GetParameter(3);
-
-  if (FLAG_trace_elements_transitions) {
-    // Tracing elements transitions is the job of the runtime.
-    current_block()->FinishExitWithDeoptimization(HDeoptimize::kUseAll);
-    set_current_block(NULL);
-    return value;
-  }
-
-  info()->MarkAsSavesCallerDoubles();
-
-  if (AllocationSite::GetMode(from_kind, to_kind) == TRACK_ALLOCATION_SITE) {
-    Add<HTrapAllocationMemento>(object);
-  }
-
-  // Check if we need to transition the array elements first
-  // (either SMI -> Double or Double -> Object).
-  if (DoesTransitionChangeElementsBufferFormat(from_kind, to_kind)) {
-    HInstruction* array_length = NULL;
-    if (stub->is_jsarray()) {
-      array_length = AddLoad(object, HObjectAccess::ForArrayLength());
-    } else {
-      array_length = AddLoadFixedArrayLength(AddLoadElements(object));
-    }
-    array_length->set_type(HType::Smi());
-
-    IfBuilder if_builder(this);
-
-    // Check if we have any elements.
-    if_builder.IfNot<HCompareNumericAndBranch>(array_length,
-                                               graph()->GetConstant0(),
-                                               Token::EQ);
-    if_builder.Then();
-
-    HInstruction* elements = AddLoadElements(object);
-
-    HInstruction* elements_length = AddLoadFixedArrayLength(elements);
-
-    BuildGrowElementsCapacity(object, elements, from_kind, to_kind,
-                              array_length, elements_length);
-
-    if_builder.End();
-  }
-
-  // Set transitioned map.
-  AddStore(object, HObjectAccess::ForMap(), target_map);
-
-  // Generate the actual store.
-  BuildUncheckedMonomorphicElementAccess(object, key, value, NULL,
-                                          stub->is_jsarray(), to_kind,
-                                          true, ALLOW_RETURN_HOLE,
-                                          stub->store_mode());
-
-  return value;
-}
-
-
-Handle<Code> ElementsTransitionAndStoreStub::GenerateCode() {
-  return DoGenerateCode(this);
-}
-
-
 } }  // namespace v8::internal
index 5f6616e..7e7125d 100644 (file)
@@ -818,6 +818,44 @@ bool ToBooleanStub::Types::CanBeUndetectable() const {
 }
 
 
+void ElementsTransitionAndStoreStub::Generate(MacroAssembler* masm) {
+  Label fail;
+  AllocationSiteMode mode = AllocationSite::GetMode(from_, to_);
+  ASSERT(!IsFastHoleyElementsKind(from_) || IsFastHoleyElementsKind(to_));
+  if (!FLAG_trace_elements_transitions) {
+    if (IsFastSmiOrObjectElementsKind(to_)) {
+      if (IsFastSmiOrObjectElementsKind(from_)) {
+        ElementsTransitionGenerator::
+            GenerateMapChangeElementsTransition(masm, mode, &fail);
+      } else if (IsFastDoubleElementsKind(from_)) {
+        ASSERT(!IsFastSmiElementsKind(to_));
+        ElementsTransitionGenerator::GenerateDoubleToObject(masm, mode, &fail);
+      } else {
+        UNREACHABLE();
+      }
+      KeyedStoreStubCompiler::GenerateStoreFastElement(masm,
+                                                       is_jsarray_,
+                                                       to_,
+                                                       store_mode_);
+    } else if (IsFastSmiElementsKind(from_) &&
+               IsFastDoubleElementsKind(to_)) {
+      ElementsTransitionGenerator::GenerateSmiToDouble(masm, mode, &fail);
+      KeyedStoreStubCompiler::GenerateStoreFastDoubleElement(masm,
+                                                             is_jsarray_,
+                                                             store_mode_);
+    } else if (IsFastDoubleElementsKind(from_)) {
+      ASSERT(to_ == FAST_HOLEY_DOUBLE_ELEMENTS);
+      ElementsTransitionGenerator::
+          GenerateMapChangeElementsTransition(masm, mode, &fail);
+    } else {
+      UNREACHABLE();
+    }
+  }
+  masm->bind(&fail);
+  KeyedStoreIC::GenerateRuntimeSetProperty(masm, strict_mode_);
+}
+
+
 void StubFailureTrampolineStub::GenerateAheadOfTime(Isolate* isolate) {
   StubFailureTrampolineStub stub1(NOT_JS_FUNCTION_STUB_MODE);
   StubFailureTrampolineStub stub2(JS_FUNCTION_STUB_MODE);
index 6f9d99e..17f9200 100644 (file)
@@ -2245,47 +2245,41 @@ class ToBooleanStub: public HydrogenCodeStub {
 };
 
 
-class ElementsTransitionAndStoreStub : public HydrogenCodeStub {
+class ElementsTransitionAndStoreStub : public PlatformCodeStub {
  public:
   ElementsTransitionAndStoreStub(ElementsKind from,
                                  ElementsKind to,
                                  bool is_jsarray,
+                                 StrictModeFlag strict_mode,
                                  KeyedAccessStoreMode store_mode)
       : from_(from),
         to_(to),
         is_jsarray_(is_jsarray),
-        store_mode_(store_mode) {
-    ASSERT(!IsFastHoleyElementsKind(from) || IsFastHoleyElementsKind(to));
-  }
-
-  ElementsKind from() const { return from_; }
-  ElementsKind to() const { return to_; }
-  bool is_jsarray() const { return is_jsarray_; }
-  KeyedAccessStoreMode store_mode() const { return store_mode_; }
-
-  Handle<Code> GenerateCode();
-
-  void InitializeInterfaceDescriptor(
-      Isolate* isolate,
-      CodeStubInterfaceDescriptor* descriptor);
+        strict_mode_(strict_mode),
+        store_mode_(store_mode) {}
 
  private:
-  class FromBits:      public BitField<ElementsKind,          0, 8> {};
-  class ToBits:        public BitField<ElementsKind,          8, 8> {};
-  class IsJSArrayBits: public BitField<bool,                 16, 1> {};
-  class StoreModeBits: public BitField<KeyedAccessStoreMode, 17, 4> {};
+  class FromBits:       public BitField<ElementsKind,        0, 8> {};
+  class ToBits:         public BitField<ElementsKind,        8, 8> {};
+  class IsJSArrayBits:  public BitField<bool,                16, 1> {};
+  class StrictModeBits: public BitField<StrictModeFlag,      17, 1> {};
+  class StoreModeBits: public BitField<KeyedAccessStoreMode, 18, 4> {};
 
   Major MajorKey() { return ElementsTransitionAndStore; }
-  int NotMissMinorKey() {
-    return FromBits::encode(from()) |
-        ToBits::encode(to()) |
-        IsJSArrayBits::encode(is_jsarray()) |
-        StoreModeBits::encode(store_mode());
+  int MinorKey() {
+    return FromBits::encode(from_) |
+        ToBits::encode(to_) |
+        IsJSArrayBits::encode(is_jsarray_) |
+        StrictModeBits::encode(strict_mode_) |
+        StoreModeBits::encode(store_mode_);
   }
 
+  void Generate(MacroAssembler* masm);
+
   ElementsKind from_;
   ElementsKind to_;
   bool is_jsarray_;
+  StrictModeFlag strict_mode_;
   KeyedAccessStoreMode store_mode_;
 
   DISALLOW_COPY_AND_ASSIGN(ElementsTransitionAndStoreStub);
index 151dde4..da15192 100644 (file)
@@ -229,15 +229,6 @@ inline bool CanTransitionToMoreGeneralFastElementsKind(
 }
 
 
-inline bool DoesTransitionChangeElementsBufferFormat(ElementsKind from_kind,
-                                                     ElementsKind to_kind) {
-  return (IsFastSmiElementsKind(from_kind) &&
-          IsFastDoubleElementsKind(to_kind)) ||
-      (IsFastDoubleElementsKind(from_kind) &&
-       IsFastObjectElementsKind(to_kind));
-}
-
-
 } }  // namespace v8::internal
 
 #endif  // V8_ELEMENTS_KIND_H_
index 50d9669..7622f4a 100644 (file)
@@ -187,7 +187,7 @@ DEFINE_implication(harmony_observation, harmony_collections)
 // Flags for experimental implementation features.
 DEFINE_bool(packed_arrays, true, "optimizes arrays that have no holes")
 DEFINE_bool(smi_only_arrays, true, "tracks arrays with only smi values")
-DEFINE_bool(compiled_transitions, false, "use optimizing compiler to "
+DEFINE_bool(compiled_transitions, true, "use optimizing compiler to "
             "generate array elements transition stubs")
 DEFINE_bool(compiled_keyed_stores, true, "use optimizing compiler to "
             "generate keyed store stubs")
index aee57dc..7cf9b44 100644 (file)
@@ -262,17 +262,6 @@ void StoreGlobalStub::InitializeInterfaceDescriptor(
 }
 
 
-void ElementsTransitionAndStoreStub::InitializeInterfaceDescriptor(
-    Isolate* isolate,
-    CodeStubInterfaceDescriptor* descriptor) {
-  static Register registers[] = { eax, ebx, ecx, edx };
-  descriptor->register_param_count_ = 4;
-  descriptor->register_params_ = registers;
-  descriptor->deoptimization_handler_ =
-      FUNCTION_ADDR(ElementsTransitionAndStoreIC_Miss);
-}
-
-
 #define __ ACCESS_MASM(masm)
 
 
index f84b3b9..2f63fee 100644 (file)
--- a/src/ic.cc
+++ b/src/ic.cc
@@ -2478,24 +2478,6 @@ RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_MissForceGeneric) {
 }
 
 
-RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss) {
-  SealHandleScope scope(isolate);
-  ASSERT(args.length() == 4);
-  KeyedStoreIC ic(IC::EXTRA_CALL_FRAME, isolate);
-  Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state();
-  Handle<Object> value = args.at<Object>(0);
-  Handle<Object> key = args.at<Object>(2);
-  Handle<Object> object = args.at<Object>(3);
-  StrictModeFlag strict_mode = Code::GetStrictMode(extra_ic_state);
-  return Runtime::SetObjectProperty(isolate,
-                                    object,
-                                    key,
-                                    value,
-                                    NONE,
-                                    strict_mode);
-}
-
-
 void BinaryOpIC::patch(Code* code) {
   set_target(code);
 }
index c9f521f..aa867cc 100644 (file)
--- a/src/ic.h
+++ b/src/ic.h
@@ -858,7 +858,6 @@ DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_MissFromStubFailure);
 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_MissFromStubFailure);
 DECLARE_RUNTIME_FUNCTION(MaybeObject*, UnaryOpIC_Miss);
 DECLARE_RUNTIME_FUNCTION(MaybeObject*, StoreIC_MissFromStubFailure);
-DECLARE_RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss);
 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss);
 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss);
 
index c4a4bdc..29178eb 100644 (file)
@@ -259,17 +259,6 @@ void StoreGlobalStub::InitializeInterfaceDescriptor(
 }
 
 
-void ElementsTransitionAndStoreStub::InitializeInterfaceDescriptor(
-    Isolate* isolate,
-    CodeStubInterfaceDescriptor* descriptor) {
-  static Register registers[] = { a0, a3, a1, a2 };
-  descriptor->register_param_count_ = 4;
-  descriptor->register_params_ = registers;
-  descriptor->deoptimization_handler_ =
-      FUNCTION_ADDR(ElementsTransitionAndStoreIC_Miss);
-}
-
-
 #define __ ACCESS_MASM(masm)
 
 
index 47ef8f5..a687d81 100644 (file)
@@ -1997,6 +1997,7 @@ Handle<Code> KeyedStoreStubCompiler::CompileStoreElementPolymorphic(
           elements_kind,
           transitioned_map->elements_kind(),
           is_js_array,
+          strict_mode(),
           store_mode_).GetCode(isolate());
     } else {
       if (FLAG_compiled_keyed_stores &&
index 0b74ace..0c0c272 100644 (file)
@@ -258,17 +258,6 @@ void StoreGlobalStub::InitializeInterfaceDescriptor(
 }
 
 
-void ElementsTransitionAndStoreStub::InitializeInterfaceDescriptor(
-    Isolate* isolate,
-    CodeStubInterfaceDescriptor* descriptor) {
-  static Register registers[] = { rax, rbx, rcx, rdx };
-  descriptor->register_param_count_ = 4;
-  descriptor->register_params_ = registers;
-  descriptor->deoptimization_handler_ =
-      FUNCTION_ADDR(ElementsTransitionAndStoreIC_Miss);
-}
-
-
 #define __ ACCESS_MASM(masm)