Commit 3416e7bc authored by haitao.feng@intel.com's avatar haitao.feng@intel.com

Return int64_t instead of intptr_t for RootRegisterDelta and support x32 as well.

R=verwaest@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20863 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 6e405733
...@@ -54,10 +54,10 @@ MacroAssembler::MacroAssembler(Isolate* arg_isolate, void* buffer, int size) ...@@ -54,10 +54,10 @@ MacroAssembler::MacroAssembler(Isolate* arg_isolate, void* buffer, int size)
} }
static const int kInvalidRootRegisterDelta = -1; static const int64_t kInvalidRootRegisterDelta = -1;
intptr_t MacroAssembler::RootRegisterDelta(ExternalReference other) { int64_t MacroAssembler::RootRegisterDelta(ExternalReference other) {
if (predictable_code_size() && if (predictable_code_size() &&
(other.address() < reinterpret_cast<Address>(isolate()) || (other.address() < reinterpret_cast<Address>(isolate()) ||
other.address() >= reinterpret_cast<Address>(isolate() + 1))) { other.address() >= reinterpret_cast<Address>(isolate() + 1))) {
...@@ -65,7 +65,18 @@ intptr_t MacroAssembler::RootRegisterDelta(ExternalReference other) { ...@@ -65,7 +65,18 @@ intptr_t MacroAssembler::RootRegisterDelta(ExternalReference other) {
} }
Address roots_register_value = kRootRegisterBias + Address roots_register_value = kRootRegisterBias +
reinterpret_cast<Address>(isolate()->heap()->roots_array_start()); reinterpret_cast<Address>(isolate()->heap()->roots_array_start());
intptr_t delta = other.address() - roots_register_value;
int64_t delta = kInvalidRootRegisterDelta; // Bogus initialization.
if (kPointerSize == kInt64Size) {
delta = other.address() - roots_register_value;
} else {
// For x32, zero extend the address to 64-bit and calculate the delta.
uint64_t o = static_cast<uint32_t>(
reinterpret_cast<intptr_t>(other.address()));
uint64_t r = static_cast<uint32_t>(
reinterpret_cast<intptr_t>(roots_register_value));
delta = o - r;
}
return delta; return delta;
} }
...@@ -73,7 +84,7 @@ intptr_t MacroAssembler::RootRegisterDelta(ExternalReference other) { ...@@ -73,7 +84,7 @@ intptr_t MacroAssembler::RootRegisterDelta(ExternalReference other) {
Operand MacroAssembler::ExternalOperand(ExternalReference target, Operand MacroAssembler::ExternalOperand(ExternalReference target,
Register scratch) { Register scratch) {
if (root_array_available_ && !Serializer::enabled()) { if (root_array_available_ && !Serializer::enabled()) {
intptr_t delta = RootRegisterDelta(target); int64_t delta = RootRegisterDelta(target);
if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { if (delta != kInvalidRootRegisterDelta && is_int32(delta)) {
return Operand(kRootRegister, static_cast<int32_t>(delta)); return Operand(kRootRegister, static_cast<int32_t>(delta));
} }
...@@ -85,7 +96,7 @@ Operand MacroAssembler::ExternalOperand(ExternalReference target, ...@@ -85,7 +96,7 @@ Operand MacroAssembler::ExternalOperand(ExternalReference target,
void MacroAssembler::Load(Register destination, ExternalReference source) { void MacroAssembler::Load(Register destination, ExternalReference source) {
if (root_array_available_ && !Serializer::enabled()) { if (root_array_available_ && !Serializer::enabled()) {
intptr_t delta = RootRegisterDelta(source); int64_t delta = RootRegisterDelta(source);
if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { if (delta != kInvalidRootRegisterDelta && is_int32(delta)) {
movp(destination, Operand(kRootRegister, static_cast<int32_t>(delta))); movp(destination, Operand(kRootRegister, static_cast<int32_t>(delta)));
return; return;
...@@ -103,7 +114,7 @@ void MacroAssembler::Load(Register destination, ExternalReference source) { ...@@ -103,7 +114,7 @@ void MacroAssembler::Load(Register destination, ExternalReference source) {
void MacroAssembler::Store(ExternalReference destination, Register source) { void MacroAssembler::Store(ExternalReference destination, Register source) {
if (root_array_available_ && !Serializer::enabled()) { if (root_array_available_ && !Serializer::enabled()) {
intptr_t delta = RootRegisterDelta(destination); int64_t delta = RootRegisterDelta(destination);
if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { if (delta != kInvalidRootRegisterDelta && is_int32(delta)) {
movp(Operand(kRootRegister, static_cast<int32_t>(delta)), source); movp(Operand(kRootRegister, static_cast<int32_t>(delta)), source);
return; return;
...@@ -122,7 +133,7 @@ void MacroAssembler::Store(ExternalReference destination, Register source) { ...@@ -122,7 +133,7 @@ void MacroAssembler::Store(ExternalReference destination, Register source) {
void MacroAssembler::LoadAddress(Register destination, void MacroAssembler::LoadAddress(Register destination,
ExternalReference source) { ExternalReference source) {
if (root_array_available_ && !Serializer::enabled()) { if (root_array_available_ && !Serializer::enabled()) {
intptr_t delta = RootRegisterDelta(source); int64_t delta = RootRegisterDelta(source);
if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { if (delta != kInvalidRootRegisterDelta && is_int32(delta)) {
leap(destination, Operand(kRootRegister, static_cast<int32_t>(delta))); leap(destination, Operand(kRootRegister, static_cast<int32_t>(delta)));
return; return;
...@@ -138,7 +149,7 @@ int MacroAssembler::LoadAddressSize(ExternalReference source) { ...@@ -138,7 +149,7 @@ int MacroAssembler::LoadAddressSize(ExternalReference source) {
// This calculation depends on the internals of LoadAddress. // This calculation depends on the internals of LoadAddress.
// It's correctness is ensured by the asserts in the Call // It's correctness is ensured by the asserts in the Call
// instruction below. // instruction below.
intptr_t delta = RootRegisterDelta(source); int64_t delta = RootRegisterDelta(source);
if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { if (delta != kInvalidRootRegisterDelta && is_int32(delta)) {
// Operand is leap(scratch, Operand(kRootRegister, delta)); // Operand is leap(scratch, Operand(kRootRegister, delta));
// Opcodes : REX.W 8D ModRM Disp8/Disp32 - 4 or 7. // Opcodes : REX.W 8D ModRM Disp8/Disp32 - 4 or 7.
......
...@@ -1465,7 +1465,7 @@ class MacroAssembler: public Assembler { ...@@ -1465,7 +1465,7 @@ class MacroAssembler: public Assembler {
// modified. It may be the "smi 1 constant" register. // modified. It may be the "smi 1 constant" register.
Register GetSmiConstant(Smi* value); Register GetSmiConstant(Smi* value);
intptr_t RootRegisterDelta(ExternalReference other); int64_t RootRegisterDelta(ExternalReference other);
// Moves the smi value to the destination register. // Moves the smi value to the destination register.
void LoadSmiConstant(Register dst, Smi* value); void LoadSmiConstant(Register dst, Smi* value);
......
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