Commit 3e49607c authored by Junliang Yan's avatar Junliang Yan Committed by Commit Bot

PPC/s390: [turbofan] Implement constant folding of string concatenations

Port fef047a4

Original Commit Message:

    This CL implements the following design doc:
    https://docs.google.com/document/d/1h5kdfemMQMpUd15PSKW1lqikJW5hsGwrmOvoqhGFRts/edit?ts=5b978756#heading=h.urs7r34mx9p

R=mslekova@chromium.org, joransiu@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=
LOG=N

Change-Id: Iac369feb7a0bfb1d878a3c0fb4a6efbee6371128
Reviewed-on: https://chromium-review.googlesource.com/1234973Reviewed-by: 's avatarJoran Siu <joransiu@ca.ibm.com>
Commit-Queue: Junliang Yan <jyan@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#56054}
parent b603513e
...@@ -74,6 +74,9 @@ class PPCOperandConverter final : public InstructionOperandConverter { ...@@ -74,6 +74,9 @@ class PPCOperandConverter final : public InstructionOperandConverter {
return Operand(constant.ToInt64()); return Operand(constant.ToInt64());
#endif #endif
case Constant::kExternalReference: case Constant::kExternalReference:
case Constant::kDelayedStringConstant:
return Operand::EmbeddedStringConstant(
constant.ToDelayedStringConstant());
case Constant::kHeapObject: case Constant::kHeapObject:
case Constant::kRpoNumber: case Constant::kRpoNumber:
break; break;
...@@ -2564,6 +2567,10 @@ void CodeGenerator::AssembleMove(InstructionOperand* source, ...@@ -2564,6 +2567,10 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
case Constant::kExternalReference: case Constant::kExternalReference:
__ Move(dst, src.ToExternalReference()); __ Move(dst, src.ToExternalReference());
break; break;
case Constant::kDelayedStringConstant:
__ mov(dst, Operand::EmbeddedStringConstant(
src.ToDelayedStringConstant()));
break;
case Constant::kHeapObject: { case Constant::kHeapObject: {
Handle<HeapObject> src_object = src.ToHeapObject(); Handle<HeapObject> src_object = src.ToHeapObject();
Heap::RootListIndex index; Heap::RootListIndex index;
......
...@@ -67,6 +67,9 @@ class S390OperandConverter final : public InstructionOperandConverter { ...@@ -67,6 +67,9 @@ class S390OperandConverter final : public InstructionOperandConverter {
return Operand(constant.ToInt64()); return Operand(constant.ToInt64());
#endif #endif
case Constant::kExternalReference: case Constant::kExternalReference:
case Constant::kDelayedStringConstant:
return Operand::EmbeddedStringConstant(
constant.ToDelayedStringConstant());
case Constant::kHeapObject: case Constant::kHeapObject:
case Constant::kRpoNumber: case Constant::kRpoNumber:
break; break;
...@@ -3170,6 +3173,10 @@ void CodeGenerator::AssembleMove(InstructionOperand* source, ...@@ -3170,6 +3173,10 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
case Constant::kExternalReference: case Constant::kExternalReference:
__ Move(dst, src.ToExternalReference()); __ Move(dst, src.ToExternalReference());
break; break;
case Constant::kDelayedStringConstant:
__ mov(dst, Operand::EmbeddedStringConstant(
src.ToDelayedStringConstant()));
break;
case Constant::kHeapObject: { case Constant::kHeapObject: {
Handle<HeapObject> src_object = src.ToHeapObject(); Handle<HeapObject> src_object = src.ToHeapObject();
Heap::RootListIndex index; Heap::RootListIndex index;
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include "src/deoptimizer.h" #include "src/deoptimizer.h"
#include "src/macro-assembler.h" #include "src/macro-assembler.h"
#include "src/ppc/assembler-ppc-inl.h" #include "src/ppc/assembler-ppc-inl.h"
#include "src/string-constants.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -211,6 +212,13 @@ Operand Operand::EmbeddedCode(CodeStub* stub) { ...@@ -211,6 +212,13 @@ Operand Operand::EmbeddedCode(CodeStub* stub) {
return result; return result;
} }
Operand Operand::EmbeddedStringConstant(const StringConstantBase* str) {
Operand result(0, RelocInfo::EMBEDDED_OBJECT);
result.is_heap_object_request_ = true;
result.value_.heap_object_request = HeapObjectRequest(str);
return result;
}
MemOperand::MemOperand(Register rn, int32_t offset) MemOperand::MemOperand(Register rn, int32_t offset)
: ra_(rn), offset_(offset), rb_(no_reg) {} : ra_(rn), offset_(offset), rb_(no_reg) {}
...@@ -222,19 +230,26 @@ void Assembler::AllocateAndInstallRequestedHeapObjects(Isolate* isolate) { ...@@ -222,19 +230,26 @@ void Assembler::AllocateAndInstallRequestedHeapObjects(Isolate* isolate) {
for (auto& request : heap_object_requests_) { for (auto& request : heap_object_requests_) {
Handle<HeapObject> object; Handle<HeapObject> object;
switch (request.kind()) { switch (request.kind()) {
case HeapObjectRequest::kHeapNumber: case HeapObjectRequest::kHeapNumber: {
object = object =
isolate->factory()->NewHeapNumber(request.heap_number(), TENURED); isolate->factory()->NewHeapNumber(request.heap_number(), TENURED);
break; break;
case HeapObjectRequest::kCodeStub: }
case HeapObjectRequest::kCodeStub: {
request.code_stub()->set_isolate(isolate); request.code_stub()->set_isolate(isolate);
object = request.code_stub()->GetCode(); object = request.code_stub()->GetCode();
break; break;
}
case HeapObjectRequest::kStringConstant: {
const StringConstantBase* str = request.string();
CHECK_NOT_NULL(str);
object = str->AllocateStringConstant(isolate);
break;
}
} }
Address pc = reinterpret_cast<Address>(buffer_) + request.offset(); Address pc = reinterpret_cast<Address>(buffer_) + request.offset();
Address constant_pool = kNullAddress; Address constant_pool = kNullAddress;
set_target_address_at(pc, constant_pool, set_target_address_at(pc, constant_pool, object.address(),
reinterpret_cast<Address>(object.location()),
SKIP_ICACHE_FLUSH); SKIP_ICACHE_FLUSH);
} }
} }
......
...@@ -394,6 +394,7 @@ class Operand { ...@@ -394,6 +394,7 @@ class Operand {
V8_INLINE explicit Operand(Register rm); V8_INLINE explicit Operand(Register rm);
static Operand EmbeddedNumber(double number); // Smi or HeapNumber. static Operand EmbeddedNumber(double number); // Smi or HeapNumber.
static Operand EmbeddedStringConstant(const StringConstantBase* str);
static Operand EmbeddedCode(CodeStub* stub); static Operand EmbeddedCode(CodeStub* stub);
// Return true if this is a register operand. // Return true if this is a register operand.
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#include "src/deoptimizer.h" #include "src/deoptimizer.h"
#include "src/macro-assembler.h" #include "src/macro-assembler.h"
#include "src/s390/assembler-s390-inl.h" #include "src/s390/assembler-s390-inl.h"
#include "src/string-constants.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -316,6 +317,13 @@ Operand Operand::EmbeddedNumber(double value) { ...@@ -316,6 +317,13 @@ Operand Operand::EmbeddedNumber(double value) {
return result; return result;
} }
Operand Operand::EmbeddedStringConstant(const StringConstantBase* str) {
Operand result(0, RelocInfo::EMBEDDED_OBJECT);
result.is_heap_object_request_ = true;
result.value_.heap_object_request = HeapObjectRequest(str);
return result;
}
MemOperand::MemOperand(Register rn, int32_t offset) MemOperand::MemOperand(Register rn, int32_t offset)
: baseRegister(rn), indexRegister(r0), offset_(offset) {} : baseRegister(rn), indexRegister(r0), offset_(offset) {}
...@@ -328,20 +336,28 @@ void Assembler::AllocateAndInstallRequestedHeapObjects(Isolate* isolate) { ...@@ -328,20 +336,28 @@ void Assembler::AllocateAndInstallRequestedHeapObjects(Isolate* isolate) {
Handle<HeapObject> object; Handle<HeapObject> object;
Address pc = reinterpret_cast<Address>(buffer_ + request.offset()); Address pc = reinterpret_cast<Address>(buffer_ + request.offset());
switch (request.kind()) { switch (request.kind()) {
case HeapObjectRequest::kHeapNumber: case HeapObjectRequest::kHeapNumber: {
object = object =
isolate->factory()->NewHeapNumber(request.heap_number(), TENURED); isolate->factory()->NewHeapNumber(request.heap_number(), TENURED);
set_target_address_at(pc, kNullAddress, set_target_address_at(pc, kNullAddress, object.address(),
reinterpret_cast<Address>(object.location()),
SKIP_ICACHE_FLUSH); SKIP_ICACHE_FLUSH);
break; break;
case HeapObjectRequest::kCodeStub: }
case HeapObjectRequest::kCodeStub: {
request.code_stub()->set_isolate(isolate); request.code_stub()->set_isolate(isolate);
SixByteInstr instr = SixByteInstr instr =
Instruction::InstructionBits(reinterpret_cast<const byte*>(pc)); Instruction::InstructionBits(reinterpret_cast<const byte*>(pc));
int index = instr & 0xFFFFFFFF; int index = instr & 0xFFFFFFFF;
UpdateCodeTarget(index, request.code_stub()->GetCode()); UpdateCodeTarget(index, request.code_stub()->GetCode());
break; break;
}
case HeapObjectRequest::kStringConstant: {
const StringConstantBase* str = request.string();
CHECK_NOT_NULL(str);
set_target_address_at(pc, kNullAddress,
str->AllocateStringConstant(isolate).address());
break;
}
} }
} }
} }
......
...@@ -368,6 +368,7 @@ class Operand { ...@@ -368,6 +368,7 @@ class Operand {
V8_INLINE explicit Operand(Register rm); V8_INLINE explicit Operand(Register rm);
static Operand EmbeddedNumber(double value); // Smi or HeapNumber static Operand EmbeddedNumber(double value); // Smi or HeapNumber
static Operand EmbeddedStringConstant(const StringConstantBase* str);
// Return true if this is a register operand. // Return true if this is a register operand.
V8_INLINE bool is_reg() const { return rm_.is_valid(); } V8_INLINE bool is_reg() const { return rm_.is_valid(); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment