Commit 08607d37 authored by Milad Fa's avatar Milad Fa Committed by V8 LUCI CQ

PPC/s390: [compiler] Remove delayed string constants

Port de04959f

Original Commit Message:

    StringConstantXXX were introduced when we switched to concurrent
    compilation, as a way to build strings in Turbofan in a background
    thread, without having to actually allocate them on the main heap
    from the background. See https://crrev.com/c/1221807.

    Now that we have local heaps, we can actually allocate strings from
    the background, making StringConstantXXX useless.

    Moreover, we would fold constant string concatenations into
    ConsString, which sounds a bit dubious for performance. Now, small
    constant string concatenations will be folded into SeqStrings, while
    larger ones will remain ConsString, just to avoid the quadratic
    worst-case.

R=dmercadier@chromium.org, joransiu@ca.ibm.com, junyan@redhat.com, midawson@redhat.com
BUG=
LOG=N

Change-Id: I0fb010dfda4a94ba8c5d09de96fa1932c6c91113
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3826049Reviewed-by: 's avatarDarius Mercadier <dmercadier@chromium.org>
Commit-Queue: Milad Farazmand <mfarazma@redhat.com>
Cr-Commit-Position: refs/heads/main@{#82416}
parent 613c2402
......@@ -46,7 +46,6 @@
#include "src/base/cpu.h"
#include "src/codegen/macro-assembler.h"
#include "src/codegen/ppc/assembler-ppc-inl.h"
#include "src/codegen/string-constants.h"
#include "src/deoptimizer/deoptimizer.h"
namespace v8 {
......@@ -194,15 +193,8 @@ Operand Operand::EmbeddedNumber(double value) {
int32_t smi;
if (DoubleToSmiInteger(value, &smi)) return Operand(Smi::FromInt(smi));
Operand result(0, RelocInfo::FULL_EMBEDDED_OBJECT);
result.is_heap_object_request_ = true;
result.value_.heap_object_request = HeapObjectRequest(value);
return result;
}
Operand Operand::EmbeddedStringConstant(const StringConstantBase* str) {
Operand result(0, RelocInfo::FULL_EMBEDDED_OBJECT);
result.is_heap_object_request_ = true;
result.value_.heap_object_request = HeapObjectRequest(str);
result.is_heap_number_request_ = true;
result.value_.heap_number_request = HeapNumberRequest(value);
return result;
}
......@@ -215,23 +207,12 @@ MemOperand::MemOperand(Register ra, Register rb)
MemOperand::MemOperand(Register ra, Register rb, int64_t offset)
: ra_(ra), offset_(offset), rb_(rb) {}
void Assembler::AllocateAndInstallRequestedHeapObjects(Isolate* isolate) {
DCHECK_IMPLIES(isolate == nullptr, heap_object_requests_.empty());
for (auto& request : heap_object_requests_) {
Handle<HeapObject> object;
switch (request.kind()) {
case HeapObjectRequest::kHeapNumber: {
object = isolate->factory()->NewHeapNumber<AllocationType::kOld>(
void Assembler::AllocateAndInstallRequestedHeapNumbers(Isolate* isolate) {
DCHECK_IMPLIES(isolate == nullptr, heap_number_requests_.empty());
for (auto& request : heap_number_requests_) {
Handle<HeapObject> object =
isolate->factory()->NewHeapNumber<AllocationType::kOld>(
request.heap_number());
break;
}
case HeapObjectRequest::kStringConstant: {
const StringConstantBase* str = request.string();
CHECK_NOT_NULL(str);
object = str->AllocateStringConstant(isolate);
break;
}
}
Address pc = reinterpret_cast<Address>(buffer_start_) + request.offset();
Address constant_pool = kNullAddress;
set_target_address_at(pc, constant_pool, object.address(),
......@@ -280,7 +261,7 @@ void Assembler::GetCode(Isolate* isolate, CodeDesc* desc,
int code_comments_size = WriteCodeComments();
AllocateAndInstallRequestedHeapObjects(isolate);
AllocateAndInstallRequestedHeapNumbers(isolate);
// Set up code descriptor.
// TODO(jgruber): Reconsider how these offsets and sizes are maintained up to
......@@ -1378,8 +1359,8 @@ bool Operand::must_output_reloc_info(const Assembler* assembler) const {
// and only use the generic version when we require a fixed sequence
void Assembler::mov(Register dst, const Operand& src) {
intptr_t value;
if (src.IsHeapObjectRequest()) {
RequestHeapObject(src.heap_object_request());
if (src.IsHeapNumberRequest()) {
RequestHeapNumber(src.heap_number_request());
value = 0;
} else {
value = src.immediate();
......@@ -1393,7 +1374,7 @@ void Assembler::mov(Register dst, const Operand& src) {
(!is_int16(value) ||
!(CpuFeatures::IsSupported(PPC_10_PLUS) && is_int34(value)))));
if (!src.IsHeapObjectRequest() &&
if (!src.IsHeapNumberRequest() &&
use_constant_pool_for_mov(dst, src, canOptimize)) {
DCHECK(is_constant_pool_available());
if (relocatable) {
......
......@@ -83,7 +83,6 @@ class V8_EXPORT_PRIVATE Operand {
V8_INLINE explicit Operand(Register rm);
static Operand EmbeddedNumber(double number); // Smi or HeapNumber.
static Operand EmbeddedStringConstant(const StringConstantBase* str);
// Return true if this is a register operand.
V8_INLINE bool is_reg() const { return rm_.is_valid(); }
......@@ -92,34 +91,34 @@ class V8_EXPORT_PRIVATE Operand {
inline intptr_t immediate() const {
DCHECK(IsImmediate());
DCHECK(!IsHeapObjectRequest());
DCHECK(!IsHeapNumberRequest());
return value_.immediate;
}
bool IsImmediate() const { return !rm_.is_valid(); }
HeapObjectRequest heap_object_request() const {
DCHECK(IsHeapObjectRequest());
return value_.heap_object_request;
HeapNumberRequest heap_number_request() const {
DCHECK(IsHeapNumberRequest());
return value_.heap_number_request;
}
Register rm() const { return rm_; }
bool IsHeapObjectRequest() const {
DCHECK_IMPLIES(is_heap_object_request_, IsImmediate());
DCHECK_IMPLIES(is_heap_object_request_,
bool IsHeapNumberRequest() const {
DCHECK_IMPLIES(is_heap_number_request_, IsImmediate());
DCHECK_IMPLIES(is_heap_number_request_,
rmode_ == RelocInfo::FULL_EMBEDDED_OBJECT ||
rmode_ == RelocInfo::CODE_TARGET);
return is_heap_object_request_;
return is_heap_number_request_;
}
private:
Register rm_ = no_reg;
union Value {
Value() {}
HeapObjectRequest heap_object_request; // if is_heap_object_request_
HeapNumberRequest heap_number_request; // if is_heap_number_request_
intptr_t immediate; // otherwise
} value_; // valid if rm_ == no_reg
bool is_heap_object_request_ = false;
bool is_heap_number_request_ = false;
RelocInfo::Mode rmode_;
......@@ -1533,7 +1532,7 @@ class Assembler : public AssemblerBase {
Trampoline trampoline_;
bool internal_trampoline_exception_;
void AllocateAndInstallRequestedHeapObjects(Isolate* isolate);
void AllocateAndInstallRequestedHeapNumbers(Isolate* isolate);
int WriteCodeComments();
......
......@@ -49,7 +49,6 @@
#include "src/base/cpu.h"
#include "src/codegen/macro-assembler.h"
#include "src/codegen/s390/assembler-s390-inl.h"
#include "src/codegen/string-constants.h"
#include "src/deoptimizer/deoptimizer.h"
namespace v8 {
......@@ -328,15 +327,8 @@ Operand Operand::EmbeddedNumber(double value) {
int32_t smi;
if (DoubleToSmiInteger(value, &smi)) return Operand(Smi::FromInt(smi));
Operand result(0, RelocInfo::FULL_EMBEDDED_OBJECT);
result.is_heap_object_request_ = true;
result.value_.heap_object_request = HeapObjectRequest(value);
return result;
}
Operand Operand::EmbeddedStringConstant(const StringConstantBase* str) {
Operand result(0, RelocInfo::FULL_EMBEDDED_OBJECT);
result.is_heap_object_request_ = true;
result.value_.heap_object_request = HeapObjectRequest(str);
result.is_heap_number_request_ = true;
result.value_.heap_number_request = HeapNumberRequest(value);
return result;
}
......@@ -346,27 +338,15 @@ MemOperand::MemOperand(Register rn, int32_t offset)
MemOperand::MemOperand(Register rx, Register rb, int32_t offset)
: baseRegister(rb), indexRegister(rx), offset_(offset) {}
void Assembler::AllocateAndInstallRequestedHeapObjects(Isolate* isolate) {
DCHECK_IMPLIES(isolate == nullptr, heap_object_requests_.empty());
for (auto& request : heap_object_requests_) {
Handle<HeapObject> object;
void Assembler::AllocateAndInstallRequestedHeapNumbers(Isolate* isolate) {
DCHECK_IMPLIES(isolate == nullptr, heap_number_requests_.empty());
for (auto& request : heap_number_requests_) {
Address pc = reinterpret_cast<Address>(buffer_start_) + request.offset();
switch (request.kind()) {
case HeapObjectRequest::kHeapNumber: {
object = isolate->factory()->NewHeapNumber<AllocationType::kOld>(
Handle<HeapObject> object =
isolate->factory()->NewHeapNumber<AllocationType::kOld>(
request.heap_number());
set_target_address_at(pc, kNullAddress, object.address(),
SKIP_ICACHE_FLUSH);
break;
}
case HeapObjectRequest::kStringConstant: {
const StringConstantBase* str = request.string();
CHECK_NOT_NULL(str);
set_target_address_at(pc, kNullAddress,
str->AllocateStringConstant(isolate).address());
break;
}
}
set_target_address_at(pc, kNullAddress, object.address(),
SKIP_ICACHE_FLUSH);
}
}
......@@ -397,7 +377,7 @@ void Assembler::GetCode(Isolate* isolate, CodeDesc* desc,
int code_comments_size = WriteCodeComments();
AllocateAndInstallRequestedHeapObjects(isolate);
AllocateAndInstallRequestedHeapNumbers(isolate);
// Set up code descriptor.
// TODO(jgruber): Reconsider how these offsets and sizes are maintained up to
......
......@@ -111,7 +111,6 @@ class V8_EXPORT_PRIVATE Operand {
V8_INLINE explicit Operand(Register rm);
static Operand EmbeddedNumber(double value); // Smi or HeapNumber
static Operand EmbeddedStringConstant(const StringConstantBase* str);
// Return true if this is a register operand.
V8_INLINE bool is_reg() const { return rm_.is_valid(); }
......@@ -120,13 +119,13 @@ class V8_EXPORT_PRIVATE Operand {
inline intptr_t immediate() const {
DCHECK(!rm_.is_valid());
DCHECK(!is_heap_object_request());
DCHECK(!is_heap_number_request());
return value_.immediate;
}
HeapObjectRequest heap_object_request() const {
DCHECK(is_heap_object_request());
return value_.heap_object_request;
HeapNumberRequest heap_number_request() const {
DCHECK(is_heap_number_request());
return value_.heap_number_request;
}
inline void setBits(int n) {
......@@ -136,12 +135,12 @@ class V8_EXPORT_PRIVATE Operand {
Register rm() const { return rm_; }
bool is_heap_object_request() const {
DCHECK_IMPLIES(is_heap_object_request_, !rm_.is_valid());
DCHECK_IMPLIES(is_heap_object_request_,
bool is_heap_number_request() const {
DCHECK_IMPLIES(is_heap_number_request_, !rm_.is_valid());
DCHECK_IMPLIES(is_heap_number_request_,
rmode_ == RelocInfo::FULL_EMBEDDED_OBJECT ||
rmode_ == RelocInfo::CODE_TARGET);
return is_heap_object_request_;
return is_heap_number_request_;
}
RelocInfo::Mode rmode() const { return rmode_; }
......@@ -150,10 +149,10 @@ class V8_EXPORT_PRIVATE Operand {
Register rm_ = no_reg;
union Value {
Value() {}
HeapObjectRequest heap_object_request; // if is_heap_object_request_
HeapNumberRequest heap_number_request; // if is_heap_number_request_
intptr_t immediate; // otherwise
} value_; // valid if rm_ == no_reg
bool is_heap_object_request_ = false;
bool is_heap_number_request_ = false;
RelocInfo::Mode rmode_;
......@@ -1467,7 +1466,7 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
void bind_to(Label* L, int pos);
void next(Label* L);
void AllocateAndInstallRequestedHeapObjects(Isolate* isolate);
void AllocateAndInstallRequestedHeapNumbers(Isolate* isolate);
int WriteCodeComments();
......
......@@ -2628,8 +2628,8 @@ void TurboAssembler::mov(Register dst, Register src) { lgr(dst, src); }
void TurboAssembler::mov(Register dst, const Operand& src) {
int64_t value = 0;
if (src.is_heap_object_request()) {
RequestHeapObject(src.heap_object_request());
if (src.is_heap_number_request()) {
RequestHeapNumber(src.heap_number_request());
} else {
value = src.immediate();
}
......
......@@ -77,9 +77,6 @@ class PPCOperandConverter final : public InstructionOperandConverter {
#endif
case Constant::kExternalReference:
return Operand(constant.ToExternalReference());
case Constant::kDelayedStringConstant:
return Operand::EmbeddedStringConstant(
constant.ToDelayedStringConstant());
case Constant::kCompressedHeapObject:
case Constant::kHeapObject:
case Constant::kRpoNumber:
......@@ -4343,10 +4340,6 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
case Constant::kExternalReference:
__ Move(dst, src.ToExternalReference());
break;
case Constant::kDelayedStringConstant:
__ mov(dst, Operand::EmbeddedStringConstant(
src.ToDelayedStringConstant()));
break;
case Constant::kHeapObject: {
Handle<HeapObject> src_object = src.ToHeapObject();
RootIndex index;
......
......@@ -72,9 +72,6 @@ class S390OperandConverter final : public InstructionOperandConverter {
#endif
case Constant::kExternalReference:
return Operand(constant.ToExternalReference());
case Constant::kDelayedStringConstant:
return Operand::EmbeddedStringConstant(
constant.ToDelayedStringConstant());
case Constant::kCompressedHeapObject:
case Constant::kHeapObject:
case Constant::kRpoNumber:
......@@ -3703,10 +3700,6 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
case Constant::kExternalReference:
__ Move(dst, src.ToExternalReference());
break;
case Constant::kDelayedStringConstant:
__ mov(dst, Operand::EmbeddedStringConstant(
src.ToDelayedStringConstant()));
break;
case Constant::kHeapObject: {
Handle<HeapObject> src_object = src.ToHeapObject();
RootIndex index;
......
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