Allow embedding of ConsString objects into code.
authormstarzinger@chromium.org <mstarzinger@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 15 Jul 2014 10:51:12 +0000 (10:51 +0000)
committermstarzinger@chromium.org <mstarzinger@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 15 Jul 2014 10:51:12 +0000 (10:51 +0000)
R=yangguo@chromium.org
BUG=v8:2803
LOG=N

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

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

13 files changed:
src/arm/assembler-arm-inl.h
src/arm64/assembler-arm64-inl.h
src/factory.cc
src/factory.h
src/hydrogen-instructions.cc
src/ia32/assembler-ia32-inl.h
src/ic.cc
src/mips/assembler-mips-inl.h
src/mips64/assembler-mips64-inl.h
src/objects-visiting-inl.h
src/objects.cc
src/x64/assembler-x64-inl.h
src/x87/assembler-x87-inl.h

index f5b901578e3a0e1d75d12dfb8ab64407e82d9360..292885d1b248d99a358db9de9d13a28ebae8cd81 100644 (file)
@@ -166,7 +166,6 @@ void RelocInfo::set_target_object(Object* target,
                                   WriteBarrierMode write_barrier_mode,
                                   ICacheFlushMode icache_flush_mode) {
   ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
-  ASSERT(!target->IsConsString());
   Assembler::set_target_address_at(pc_, host_,
                                    reinterpret_cast<Address>(target),
                                    icache_flush_mode);
index a0bcb77e6b5cd7f0eb8bdadfe17119ba01728397..1454adf44c9c947f81117137f90a2598333dde64 100644 (file)
@@ -716,7 +716,6 @@ void RelocInfo::set_target_object(Object* target,
                                   WriteBarrierMode write_barrier_mode,
                                   ICacheFlushMode icache_flush_mode) {
   ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
-  ASSERT(!target->IsConsString());
   Assembler::set_target_address_at(pc_, host_,
                                    reinterpret_cast<Address>(target),
                                    icache_flush_mode);
index 36511d6ade409bfb019a484c94dfbaaaa8c1c914..4c142c604a88948273e612fc5bf7dd4e6cb3d5de 100644 (file)
@@ -543,19 +543,6 @@ MaybeHandle<String> Factory::NewConsString(Handle<String> left,
 }
 
 
-Handle<String> Factory::NewFlatConcatString(Handle<String> first,
-                                            Handle<String> second) {
-  int total_length = first->length() + second->length();
-  if (first->IsOneByteRepresentation() && second->IsOneByteRepresentation()) {
-    return ConcatStringContent<uint8_t>(
-        NewRawOneByteString(total_length).ToHandleChecked(), first, second);
-  } else {
-    return ConcatStringContent<uc16>(
-        NewRawTwoByteString(total_length).ToHandleChecked(), first, second);
-  }
-}
-
-
 Handle<String> Factory::NewProperSubString(Handle<String> str,
                                            int begin,
                                            int end) {
index b91b246c70f9074977df0eb7abb32e4771a6b3aa..4dd1974fcddb198e373f5d5cf04af18afd5ccd32 100644 (file)
@@ -197,10 +197,6 @@ class Factory V8_FINAL {
   MUST_USE_RESULT MaybeHandle<String> NewConsString(Handle<String> left,
                                                     Handle<String> right);
 
-  // Create a new sequential string containing the concatenation of the inputs.
-  Handle<String> NewFlatConcatString(Handle<String> first,
-                                     Handle<String> second);
-
   // Create a new string object which holds a proper substring of a string.
   Handle<String> NewProperSubString(Handle<String> str,
                                     int begin,
index bea3cea9f68865657cac588f75a589eb6fed8029..7598d61cb683f37e2ccf7cd79cee03b65f6faca8 100644 (file)
@@ -4067,10 +4067,9 @@ HInstruction* HStringAdd::New(Zone* zone,
       Handle<String> right_string = c_right->StringValue();
       // Prevent possible exception by invalid string length.
       if (left_string->length() + right_string->length() < String::kMaxLength) {
-        Handle<String> concat = zone->isolate()->factory()->NewFlatConcatString(
+        MaybeHandle<String> concat = zone->isolate()->factory()->NewConsString(
             c_left->StringValue(), c_right->StringValue());
-        ASSERT(!concat.is_null());
-        return HConstant::New(zone, context, concat);
+        return HConstant::New(zone, context, concat.ToHandleChecked());
       }
     }
   }
index 9531c695e3a95cb5b14096a77b8dd7e53034d48a..ff8978c966b2274ee0883742d5dabdf803356f07 100644 (file)
@@ -141,7 +141,6 @@ void RelocInfo::set_target_object(Object* target,
                                   WriteBarrierMode write_barrier_mode,
                                   ICacheFlushMode icache_flush_mode) {
   ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
-  ASSERT(!target->IsConsString());
   Memory::Object_at(pc_) = target;
   if (icache_flush_mode != SKIP_ICACHE_FLUSH) {
     CpuFeatures::FlushICache(pc_, sizeof(Address));
index 2b9e29c3c1bf78b8abab0cf23c686f67ffaf5e48..ac442fbcc3f70813e6a6d1bdf53e593684a32da5 100644 (file)
--- a/src/ic.cc
+++ b/src/ic.cc
@@ -992,9 +992,6 @@ Handle<Code> LoadIC::CompileHandler(LookupResult* lookup,
     }
     case CONSTANT: {
       Handle<Object> constant(lookup->GetConstant(), isolate());
-      // TODO(2803): Don't compute a stub for cons strings because they cannot
-      // be embedded into code.
-      if (constant->IsConsString()) break;
       return compiler.CompileLoadConstant(type, holder, name, constant);
     }
     case NORMAL:
index 086e55a6f48dee5fae170a69be02d28a74ea2ffe..cf8865b875d690db6e35dcad7fc6e74b06d425f6 100644 (file)
@@ -207,7 +207,6 @@ void RelocInfo::set_target_object(Object* target,
                                   WriteBarrierMode write_barrier_mode,
                                   ICacheFlushMode icache_flush_mode) {
   ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
-  ASSERT(!target->IsConsString());
   Assembler::set_target_address_at(pc_, host_,
                                    reinterpret_cast<Address>(target),
                                    icache_flush_mode);
index 776fe567910d52119fa74eff1bd51e9ad231ff8b..9c6d1573a24bd1e76ca4835d5896f2950fccf530 100644 (file)
@@ -201,7 +201,6 @@ void RelocInfo::set_target_object(Object* target,
                                   WriteBarrierMode write_barrier_mode,
                                   ICacheFlushMode icache_flush_mode) {
   ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
-  ASSERT(!target->IsConsString());
   Assembler::set_target_address_at(pc_, host_,
                                    reinterpret_cast<Address>(target),
                                    icache_flush_mode);
index 887a3de868f69bd650e7ad11ac605117203b0d38..f7341c98e3e7ae869c0d67bf049b35f8ea3511df 100644 (file)
@@ -237,7 +237,6 @@ template<typename StaticVisitor>
 void StaticMarkingVisitor<StaticVisitor>::VisitEmbeddedPointer(
     Heap* heap, RelocInfo* rinfo) {
   ASSERT(rinfo->rmode() == RelocInfo::EMBEDDED_OBJECT);
-  ASSERT(!rinfo->target_object()->IsConsString());
   HeapObject* object = HeapObject::cast(rinfo->target_object());
   heap->mark_compact_collector()->RecordRelocSlot(rinfo, object);
   // TODO(ulan): It could be better to record slots only for strongly embedded
index 584dba5998c0e461383e3668678f2dc5b73d78eb..fc78e53ca90242a36e730d7283e6eb2bfcd902d0 100644 (file)
@@ -16900,10 +16900,9 @@ Handle<HeapType> PropertyCell::UpdatedType(Handle<PropertyCell> cell,
                                            Handle<Object> value) {
   Isolate* isolate = cell->GetIsolate();
   Handle<HeapType> old_type(cell->type(), isolate);
-  // TODO(2803): Do not track ConsString as constant because they cannot be
-  // embedded into code.
-  Handle<HeapType> new_type = value->IsConsString() || value->IsTheHole()
-      ? HeapType::Any(isolate) : HeapType::Constant(value, isolate);
+  Handle<HeapType> new_type = value->IsTheHole()
+                                  ? HeapType::Any(isolate)
+                                  : HeapType::Constant(value, isolate);
 
   if (new_type->Is(old_type)) {
     return old_type;
index 0006481996e3ac3781790cd4b49ae40c6e64790f..299ef29818dca9dae13701ad1a6dff67fe96f535 100644 (file)
@@ -307,7 +307,6 @@ void RelocInfo::set_target_object(Object* target,
                                   WriteBarrierMode write_barrier_mode,
                                   ICacheFlushMode icache_flush_mode) {
   ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
-  ASSERT(!target->IsConsString());
   Memory::Object_at(pc_) = target;
   if (icache_flush_mode != SKIP_ICACHE_FLUSH) {
     CpuFeatures::FlushICache(pc_, sizeof(Address));
index e1682926201ae00f823d3b002a6578c11886623c..07a8751099c1c6844397332b30501f7d216a806c 100644 (file)
@@ -142,7 +142,6 @@ void RelocInfo::set_target_object(Object* target,
                                   WriteBarrierMode write_barrier_mode,
                                   ICacheFlushMode icache_flush_mode) {
   ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
-  ASSERT(!target->IsConsString());
   Memory::Object_at(pc_) = target;
   if (icache_flush_mode != SKIP_ICACHE_FLUSH) {
     CpuFeatures::FlushICache(pc_, sizeof(Address));