Commit 508f122d authored by jochen's avatar jochen Committed by Commit bot

Pass an isolate to RelocInfo

It needs ot to flush icaches all over the place

BUG=v8:2487
LOG=n
R=yangguo@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#32371}
parent 7ceaf727
...@@ -3659,6 +3659,7 @@ void Assembler::GrowBuffer() { ...@@ -3659,6 +3659,7 @@ void Assembler::GrowBuffer() {
desc.instr_size = pc_offset(); desc.instr_size = pc_offset();
desc.reloc_size = (buffer_ + buffer_size_) - reloc_info_writer.pos(); desc.reloc_size = (buffer_ + buffer_size_) - reloc_info_writer.pos();
desc.origin = this;
// Copy the data. // Copy the data.
int pc_delta = desc.buffer - buffer_; int pc_delta = desc.buffer - buffer_;
...@@ -3734,7 +3735,7 @@ void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { ...@@ -3734,7 +3735,7 @@ void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) {
data = RecordedAstId().ToInt(); data = RecordedAstId().ToInt();
ClearRecordedAstId(); ClearRecordedAstId();
} }
RelocInfo rinfo(pc_, rmode, data, NULL); RelocInfo rinfo(isolate(), pc_, rmode, data, NULL);
reloc_info_writer.Write(&rinfo); reloc_info_writer.Write(&rinfo);
} }
......
...@@ -2831,6 +2831,7 @@ void Assembler::GrowBuffer() { ...@@ -2831,6 +2831,7 @@ void Assembler::GrowBuffer() {
// Set up new buffer. // Set up new buffer.
desc.buffer = NewArray<byte>(desc.buffer_size); desc.buffer = NewArray<byte>(desc.buffer_size);
desc.origin = this;
desc.instr_size = pc_offset(); desc.instr_size = pc_offset();
desc.reloc_size = desc.reloc_size =
...@@ -2868,7 +2869,7 @@ void Assembler::GrowBuffer() { ...@@ -2868,7 +2869,7 @@ void Assembler::GrowBuffer() {
void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) {
// We do not try to reuse pool constants. // We do not try to reuse pool constants.
RelocInfo rinfo(reinterpret_cast<byte*>(pc_), rmode, data, NULL); RelocInfo rinfo(isolate(), reinterpret_cast<byte*>(pc_), rmode, data, NULL);
if (((rmode >= RelocInfo::COMMENT) && if (((rmode >= RelocInfo::COMMENT) &&
(rmode <= RelocInfo::DEBUG_BREAK_SLOT_AT_CONSTRUCT_CALL)) || (rmode <= RelocInfo::DEBUG_BREAK_SLOT_AT_CONSTRUCT_CALL)) ||
(rmode == RelocInfo::INTERNAL_REFERENCE) || (rmode == RelocInfo::INTERNAL_REFERENCE) ||
...@@ -2897,8 +2898,8 @@ void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { ...@@ -2897,8 +2898,8 @@ void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) {
} }
DCHECK(buffer_space() >= kMaxRelocSize); // too late to grow buffer here DCHECK(buffer_space() >= kMaxRelocSize); // too late to grow buffer here
if (rmode == RelocInfo::CODE_TARGET_WITH_ID) { if (rmode == RelocInfo::CODE_TARGET_WITH_ID) {
RelocInfo reloc_info_with_ast_id( RelocInfo reloc_info_with_ast_id(isolate(), reinterpret_cast<byte*>(pc_),
reinterpret_cast<byte*>(pc_), rmode, RecordedAstId().ToInt(), NULL); rmode, RecordedAstId().ToInt(), NULL);
ClearRecordedAstId(); ClearRecordedAstId();
reloc_info_writer.Write(&reloc_info_with_ast_id); reloc_info_writer.Write(&reloc_info_with_ast_id);
} else { } else {
...@@ -2987,9 +2988,8 @@ bool Assembler::ShouldEmitVeneer(int max_reachable_pc, int margin) { ...@@ -2987,9 +2988,8 @@ bool Assembler::ShouldEmitVeneer(int max_reachable_pc, int margin) {
void Assembler::RecordVeneerPool(int location_offset, int size) { void Assembler::RecordVeneerPool(int location_offset, int size) {
RelocInfo rinfo(buffer_ + location_offset, RelocInfo rinfo(isolate(), buffer_ + location_offset, RelocInfo::VENEER_POOL,
RelocInfo::VENEER_POOL, static_cast<intptr_t>(size), static_cast<intptr_t>(size), NULL);
NULL);
reloc_info_writer.Write(&rinfo); reloc_info_writer.Write(&rinfo);
} }
......
...@@ -741,7 +741,8 @@ void RelocIterator::next() { ...@@ -741,7 +741,8 @@ void RelocIterator::next() {
} }
RelocIterator::RelocIterator(Code* code, int mode_mask) { RelocIterator::RelocIterator(Code* code, int mode_mask)
: rinfo_(code->map()->GetIsolate()) {
rinfo_.host_ = code; rinfo_.host_ = code;
rinfo_.pc_ = code->instruction_start(); rinfo_.pc_ = code->instruction_start();
rinfo_.data_ = 0; rinfo_.data_ = 0;
...@@ -766,7 +767,8 @@ RelocIterator::RelocIterator(Code* code, int mode_mask) { ...@@ -766,7 +767,8 @@ RelocIterator::RelocIterator(Code* code, int mode_mask) {
} }
RelocIterator::RelocIterator(const CodeDesc& desc, int mode_mask) { RelocIterator::RelocIterator(const CodeDesc& desc, int mode_mask)
: rinfo_(desc.origin->isolate()) {
rinfo_.pc_ = desc.buffer; rinfo_.pc_ = desc.buffer;
rinfo_.data_ = 0; rinfo_.data_ = 0;
// Relocation info is read backwards. // Relocation info is read backwards.
......
...@@ -432,10 +432,13 @@ class RelocInfo { ...@@ -432,10 +432,13 @@ class RelocInfo {
STATIC_ASSERT(NUMBER_OF_MODES <= kBitsPerInt); STATIC_ASSERT(NUMBER_OF_MODES <= kBitsPerInt);
RelocInfo() {} explicit RelocInfo(Isolate* isolate) : isolate_(isolate) {
DCHECK_NOT_NULL(isolate);
}
RelocInfo(byte* pc, Mode rmode, intptr_t data, Code* host) RelocInfo(Isolate* isolate, byte* pc, Mode rmode, intptr_t data, Code* host)
: pc_(pc), rmode_(rmode), data_(data), host_(host) { : isolate_(isolate), pc_(pc), rmode_(rmode), data_(data), host_(host) {
DCHECK_NOT_NULL(isolate);
} }
static inline bool IsRealRelocMode(Mode mode) { static inline bool IsRealRelocMode(Mode mode) {
...@@ -518,6 +521,7 @@ class RelocInfo { ...@@ -518,6 +521,7 @@ class RelocInfo {
static inline int ModeMask(Mode mode) { return 1 << mode; } static inline int ModeMask(Mode mode) { return 1 << mode; }
// Accessors // Accessors
Isolate* isolate() const { return isolate_; }
byte* pc() const { return pc_; } byte* pc() const { return pc_; }
void set_pc(byte* pc) { pc_ = pc; } void set_pc(byte* pc) { pc_ = pc; }
Mode rmode() const { return rmode_; } Mode rmode() const { return rmode_; }
...@@ -658,6 +662,7 @@ class RelocInfo { ...@@ -658,6 +662,7 @@ class RelocInfo {
static const int kApplyMask; // Modes affected by apply. Depends on arch. static const int kApplyMask; // Modes affected by apply. Depends on arch.
private: private:
Isolate* isolate_;
// On ARM, note that pc_ is the address of the constant pool entry // On ARM, note that pc_ is the address of the constant pool entry
// to be relocated and not the address of the instruction // to be relocated and not the address of the instruction
// referencing the constant pool entry (except when rmode_ == // referencing the constant pool entry (except when rmode_ ==
......
...@@ -106,7 +106,7 @@ class BreakLocation { ...@@ -106,7 +106,7 @@ class BreakLocation {
inline RelocInfo rinfo() const { inline RelocInfo rinfo() const {
return RelocInfo(pc(), rmode(), data_, code()); return RelocInfo(debug_info_->GetIsolate(), pc(), rmode(), data_, code());
} }
inline int position() const { return position_; } inline int position() const { return position_; }
......
...@@ -1307,7 +1307,8 @@ static Handle<Code> PatchPositionsInCode( ...@@ -1307,7 +1307,8 @@ static Handle<Code> PatchPositionsInCode(
int new_position = TranslatePosition(position, int new_position = TranslatePosition(position,
position_change_array); position_change_array);
if (position != new_position) { if (position != new_position) {
RelocInfo info_copy(rinfo->pc(), rinfo->rmode(), new_position, NULL); RelocInfo info_copy(rinfo->isolate(), rinfo->pc(), rinfo->rmode(),
new_position, NULL);
buffer_writer.Write(&info_copy); buffer_writer.Write(&info_copy);
continue; continue;
} }
......
...@@ -155,7 +155,8 @@ static int DecodeIt(Isolate* isolate, std::ostream* os, ...@@ -155,7 +155,8 @@ static int DecodeIt(Isolate* isolate, std::ostream* os,
// Print all the reloc info for this instruction which are not comments. // Print all the reloc info for this instruction which are not comments.
for (int i = 0; i < pcs.length(); i++) { for (int i = 0; i < pcs.length(); i++) {
// Put together the reloc info // Put together the reloc info
RelocInfo relocinfo(pcs[i], rmodes[i], datas[i], converter.code()); RelocInfo relocinfo(isolate, pcs[i], rmodes[i], datas[i],
converter.code());
// Indent the printing of the reloc info. // Indent the printing of the reloc info.
if (i == 0) { if (i == 0) {
......
...@@ -108,7 +108,7 @@ void IncrementalMarking::RecordWriteFromCode(HeapObject* obj, Object** slot, ...@@ -108,7 +108,7 @@ void IncrementalMarking::RecordWriteFromCode(HeapObject* obj, Object** slot,
void IncrementalMarking::RecordCodeTargetPatch(Code* host, Address pc, void IncrementalMarking::RecordCodeTargetPatch(Code* host, Address pc,
HeapObject* value) { HeapObject* value) {
if (IsMarking()) { if (IsMarking()) {
RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); RelocInfo rinfo(heap_->isolate(), pc, RelocInfo::CODE_TARGET, 0, host);
RecordWriteIntoCode(host, &rinfo, value); RecordWriteIntoCode(host, &rinfo, value);
} }
} }
...@@ -119,7 +119,7 @@ void IncrementalMarking::RecordCodeTargetPatch(Address pc, HeapObject* value) { ...@@ -119,7 +119,7 @@ void IncrementalMarking::RecordCodeTargetPatch(Address pc, HeapObject* value) {
Code* host = heap_->isolate() Code* host = heap_->isolate()
->inner_pointer_to_code_cache() ->inner_pointer_to_code_cache()
->GcSafeFindCodeForInnerPointer(pc); ->GcSafeFindCodeForInnerPointer(pc);
RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); RelocInfo rinfo(heap_->isolate(), pc, RelocInfo::CODE_TARGET, 0, host);
RecordWriteIntoCode(host, &rinfo, value); RecordWriteIntoCode(host, &rinfo, value);
} }
} }
......
...@@ -2825,12 +2825,12 @@ static inline void UpdateSlot(Isolate* isolate, ObjectVisitor* v, ...@@ -2825,12 +2825,12 @@ static inline void UpdateSlot(Isolate* isolate, ObjectVisitor* v,
SlotsBuffer::SlotType slot_type, Address addr) { SlotsBuffer::SlotType slot_type, Address addr) {
switch (slot_type) { switch (slot_type) {
case SlotsBuffer::CODE_TARGET_SLOT: { case SlotsBuffer::CODE_TARGET_SLOT: {
RelocInfo rinfo(addr, RelocInfo::CODE_TARGET, 0, NULL); RelocInfo rinfo(isolate, addr, RelocInfo::CODE_TARGET, 0, NULL);
rinfo.Visit(isolate, v); rinfo.Visit(isolate, v);
break; break;
} }
case SlotsBuffer::CELL_TARGET_SLOT: { case SlotsBuffer::CELL_TARGET_SLOT: {
RelocInfo rinfo(addr, RelocInfo::CELL, 0, NULL); RelocInfo rinfo(isolate, addr, RelocInfo::CELL, 0, NULL);
rinfo.Visit(isolate, v); rinfo.Visit(isolate, v);
break; break;
} }
...@@ -2844,12 +2844,13 @@ static inline void UpdateSlot(Isolate* isolate, ObjectVisitor* v, ...@@ -2844,12 +2844,13 @@ static inline void UpdateSlot(Isolate* isolate, ObjectVisitor* v,
break; break;
} }
case SlotsBuffer::DEBUG_TARGET_SLOT: { case SlotsBuffer::DEBUG_TARGET_SLOT: {
RelocInfo rinfo(addr, RelocInfo::DEBUG_BREAK_SLOT_AT_POSITION, 0, NULL); RelocInfo rinfo(isolate, addr, RelocInfo::DEBUG_BREAK_SLOT_AT_POSITION, 0,
NULL);
if (rinfo.IsPatchedDebugBreakSlotSequence()) rinfo.Visit(isolate, v); if (rinfo.IsPatchedDebugBreakSlotSequence()) rinfo.Visit(isolate, v);
break; break;
} }
case SlotsBuffer::EMBEDDED_OBJECT_SLOT: { case SlotsBuffer::EMBEDDED_OBJECT_SLOT: {
RelocInfo rinfo(addr, RelocInfo::EMBEDDED_OBJECT, 0, NULL); RelocInfo rinfo(isolate, addr, RelocInfo::EMBEDDED_OBJECT, 0, NULL);
rinfo.Visit(isolate, v); rinfo.Visit(isolate, v);
break; break;
} }
...@@ -4166,7 +4167,7 @@ void MarkCompactCollector::RecordCodeTargetPatch(Address pc, Code* target) { ...@@ -4166,7 +4167,7 @@ void MarkCompactCollector::RecordCodeTargetPatch(Address pc, Code* target) {
pc); pc);
MarkBit mark_bit = Marking::MarkBitFrom(host); MarkBit mark_bit = Marking::MarkBitFrom(host);
if (Marking::IsBlack(mark_bit)) { if (Marking::IsBlack(mark_bit)) {
RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host);
RecordRelocSlot(&rinfo, target); RecordRelocSlot(&rinfo, target);
} }
} }
......
...@@ -133,7 +133,7 @@ void RelocInfo::set_target_object(Object* target, ...@@ -133,7 +133,7 @@ void RelocInfo::set_target_object(Object* target,
DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
Memory::Object_at(pc_) = target; Memory::Object_at(pc_) = target;
if (icache_flush_mode != SKIP_ICACHE_FLUSH) { if (icache_flush_mode != SKIP_ICACHE_FLUSH) {
Assembler::FlushICacheWithoutIsolate(pc_, sizeof(Address)); Assembler::FlushICache(isolate_, pc_, sizeof(Address));
} }
if (write_barrier_mode == UPDATE_WRITE_BARRIER && if (write_barrier_mode == UPDATE_WRITE_BARRIER &&
host() != NULL && host() != NULL &&
...@@ -199,7 +199,7 @@ void RelocInfo::set_target_cell(Cell* cell, ...@@ -199,7 +199,7 @@ void RelocInfo::set_target_cell(Cell* cell,
Address address = cell->address() + Cell::kValueOffset; Address address = cell->address() + Cell::kValueOffset;
Memory::Address_at(pc_) = address; Memory::Address_at(pc_) = address;
if (icache_flush_mode != SKIP_ICACHE_FLUSH) { if (icache_flush_mode != SKIP_ICACHE_FLUSH) {
Assembler::FlushICacheWithoutIsolate(pc_, sizeof(Address)); Assembler::FlushICache(isolate_, pc_, sizeof(Address));
} }
if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL) { if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL) {
// TODO(1550) We are passing NULL as a slot because cell can never be on // TODO(1550) We are passing NULL as a slot because cell can never be on
...@@ -280,7 +280,7 @@ void RelocInfo::Visit(Isolate* isolate, ObjectVisitor* visitor) { ...@@ -280,7 +280,7 @@ void RelocInfo::Visit(Isolate* isolate, ObjectVisitor* visitor) {
RelocInfo::Mode mode = rmode(); RelocInfo::Mode mode = rmode();
if (mode == RelocInfo::EMBEDDED_OBJECT) { if (mode == RelocInfo::EMBEDDED_OBJECT) {
visitor->VisitEmbeddedPointer(this); visitor->VisitEmbeddedPointer(this);
Assembler::FlushICacheWithoutIsolate(pc_, sizeof(Address)); Assembler::FlushICache(isolate, pc_, sizeof(Address));
} else if (RelocInfo::IsCodeTarget(mode)) { } else if (RelocInfo::IsCodeTarget(mode)) {
visitor->VisitCodeTarget(this); visitor->VisitCodeTarget(this);
} else if (mode == RelocInfo::CELL) { } else if (mode == RelocInfo::CELL) {
......
...@@ -2776,6 +2776,7 @@ void Assembler::GrowBuffer() { ...@@ -2776,6 +2776,7 @@ void Assembler::GrowBuffer() {
// Set up new buffer. // Set up new buffer.
desc.buffer = NewArray<byte>(desc.buffer_size); desc.buffer = NewArray<byte>(desc.buffer_size);
desc.origin = this;
desc.instr_size = pc_offset(); desc.instr_size = pc_offset();
desc.reloc_size = (buffer_ + buffer_size_) - (reloc_info_writer.pos()); desc.reloc_size = (buffer_ + buffer_size_) - (reloc_info_writer.pos());
...@@ -2912,7 +2913,7 @@ void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { ...@@ -2912,7 +2913,7 @@ void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) {
!serializer_enabled() && !emit_debug_code()) { !serializer_enabled() && !emit_debug_code()) {
return; return;
} }
RelocInfo rinfo(pc_, rmode, data, NULL); RelocInfo rinfo(isolate(), pc_, rmode, data, NULL);
reloc_info_writer.Write(&rinfo); reloc_info_writer.Write(&rinfo);
} }
......
...@@ -75,7 +75,7 @@ void Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(Handle<Code> code) { ...@@ -75,7 +75,7 @@ void Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(Handle<Code> code) {
new_reloc->GetDataStartAddress() + padding, 0); new_reloc->GetDataStartAddress() + padding, 0);
intptr_t comment_string intptr_t comment_string
= reinterpret_cast<intptr_t>(RelocInfo::kFillerCommentString); = reinterpret_cast<intptr_t>(RelocInfo::kFillerCommentString);
RelocInfo rinfo(0, RelocInfo::COMMENT, comment_string, NULL); RelocInfo rinfo(isolate, 0, RelocInfo::COMMENT, comment_string, NULL);
for (int i = 0; i < additional_comments; ++i) { for (int i = 0; i < additional_comments; ++i) {
#ifdef DEBUG #ifdef DEBUG
byte* pos_before = reloc_info_writer.pos(); byte* pos_before = reloc_info_writer.pos();
...@@ -142,10 +142,9 @@ void Deoptimizer::PatchCodeForDeoptimization(Isolate* isolate, Code* code) { ...@@ -142,10 +142,9 @@ void Deoptimizer::PatchCodeForDeoptimization(Isolate* isolate, Code* code) {
Address deopt_entry = GetDeoptimizationEntry(isolate, i, LAZY); Address deopt_entry = GetDeoptimizationEntry(isolate, i, LAZY);
patcher.masm()->call(deopt_entry, RelocInfo::NONE32); patcher.masm()->call(deopt_entry, RelocInfo::NONE32);
// We use RUNTIME_ENTRY for deoptimization bailouts. // We use RUNTIME_ENTRY for deoptimization bailouts.
RelocInfo rinfo(call_address + 1, // 1 after the call opcode. RelocInfo rinfo(isolate, call_address + 1, // 1 after the call opcode.
RelocInfo::RUNTIME_ENTRY, RelocInfo::RUNTIME_ENTRY,
reinterpret_cast<intptr_t>(deopt_entry), reinterpret_cast<intptr_t>(deopt_entry), NULL);
NULL);
reloc_info_writer.Write(&rinfo); reloc_info_writer.Write(&rinfo);
DCHECK_GE(reloc_info_writer.pos(), DCHECK_GE(reloc_info_writer.pos(),
reloc_info->address() + ByteArray::kHeaderSize); reloc_info->address() + ByteArray::kHeaderSize);
......
...@@ -92,7 +92,7 @@ void RelocInfo::apply(intptr_t delta) { ...@@ -92,7 +92,7 @@ void RelocInfo::apply(intptr_t delta) {
// Absolute code pointer inside code object moves with the code object. // Absolute code pointer inside code object moves with the code object.
byte* p = reinterpret_cast<byte*>(pc_); byte* p = reinterpret_cast<byte*>(pc_);
int count = Assembler::RelocateInternalReference(rmode_, p, delta); int count = Assembler::RelocateInternalReference(rmode_, p, delta);
Assembler::FlushICacheWithoutIsolate(p, count * sizeof(uint32_t)); Assembler::FlushICache(isolate_, p, count * sizeof(uint32_t));
} }
} }
......
...@@ -2815,6 +2815,7 @@ void Assembler::GrowBuffer() { ...@@ -2815,6 +2815,7 @@ void Assembler::GrowBuffer() {
// Set up new buffer. // Set up new buffer.
desc.buffer = NewArray<byte>(desc.buffer_size); desc.buffer = NewArray<byte>(desc.buffer_size);
desc.origin = this;
desc.instr_size = pc_offset(); desc.instr_size = pc_offset();
desc.reloc_size = (buffer_ + buffer_size_) - reloc_info_writer.pos(); desc.reloc_size = (buffer_ + buffer_size_) - reloc_info_writer.pos();
...@@ -2893,7 +2894,7 @@ void Assembler::emit_code_stub_address(Code* stub) { ...@@ -2893,7 +2894,7 @@ void Assembler::emit_code_stub_address(Code* stub) {
void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) {
// We do not try to reuse pool constants. // We do not try to reuse pool constants.
RelocInfo rinfo(pc_, rmode, data, NULL); RelocInfo rinfo(isolate(), pc_, rmode, data, NULL);
if (rmode >= RelocInfo::COMMENT && if (rmode >= RelocInfo::COMMENT &&
rmode <= RelocInfo::DEBUG_BREAK_SLOT_AT_CONSTRUCT_CALL) { rmode <= RelocInfo::DEBUG_BREAK_SLOT_AT_CONSTRUCT_CALL) {
// Adjust code for new modes. // Adjust code for new modes.
...@@ -2910,10 +2911,8 @@ void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { ...@@ -2910,10 +2911,8 @@ void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) {
} }
DCHECK(buffer_space() >= kMaxRelocSize); // Too late to grow buffer here. DCHECK(buffer_space() >= kMaxRelocSize); // Too late to grow buffer here.
if (rmode == RelocInfo::CODE_TARGET_WITH_ID) { if (rmode == RelocInfo::CODE_TARGET_WITH_ID) {
RelocInfo reloc_info_with_ast_id(pc_, RelocInfo reloc_info_with_ast_id(isolate(), pc_, rmode,
rmode, RecordedAstId().ToInt(), NULL);
RecordedAstId().ToInt(),
NULL);
ClearRecordedAstId(); ClearRecordedAstId();
reloc_info_writer.Write(&reloc_info_with_ast_id); reloc_info_writer.Write(&reloc_info_with_ast_id);
} else { } else {
......
...@@ -92,7 +92,7 @@ void RelocInfo::apply(intptr_t delta) { ...@@ -92,7 +92,7 @@ void RelocInfo::apply(intptr_t delta) {
// Absolute code pointer inside code object moves with the code object. // Absolute code pointer inside code object moves with the code object.
byte* p = reinterpret_cast<byte*>(pc_); byte* p = reinterpret_cast<byte*>(pc_);
int count = Assembler::RelocateInternalReference(rmode_, p, delta); int count = Assembler::RelocateInternalReference(rmode_, p, delta);
Assembler::FlushICacheWithoutIsolate(p, count * sizeof(uint32_t)); Assembler::FlushICache(isolate_, p, count * sizeof(uint32_t));
} }
} }
......
...@@ -3024,6 +3024,7 @@ void Assembler::GrowBuffer() { ...@@ -3024,6 +3024,7 @@ void Assembler::GrowBuffer() {
// Set up new buffer. // Set up new buffer.
desc.buffer = NewArray<byte>(desc.buffer_size); desc.buffer = NewArray<byte>(desc.buffer_size);
desc.origin = this;
desc.instr_size = pc_offset(); desc.instr_size = pc_offset();
desc.reloc_size = desc.reloc_size =
...@@ -3103,7 +3104,7 @@ void Assembler::emit_code_stub_address(Code* stub) { ...@@ -3103,7 +3104,7 @@ void Assembler::emit_code_stub_address(Code* stub) {
void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) {
// We do not try to reuse pool constants. // We do not try to reuse pool constants.
RelocInfo rinfo(pc_, rmode, data, NULL); RelocInfo rinfo(isolate(), pc_, rmode, data, NULL);
if (rmode >= RelocInfo::COMMENT && if (rmode >= RelocInfo::COMMENT &&
rmode <= RelocInfo::DEBUG_BREAK_SLOT_AT_CONSTRUCT_CALL) { rmode <= RelocInfo::DEBUG_BREAK_SLOT_AT_CONSTRUCT_CALL) {
// Adjust code for new modes. // Adjust code for new modes.
...@@ -3120,10 +3121,8 @@ void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { ...@@ -3120,10 +3121,8 @@ void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) {
} }
DCHECK(buffer_space() >= kMaxRelocSize); // Too late to grow buffer here. DCHECK(buffer_space() >= kMaxRelocSize); // Too late to grow buffer here.
if (rmode == RelocInfo::CODE_TARGET_WITH_ID) { if (rmode == RelocInfo::CODE_TARGET_WITH_ID) {
RelocInfo reloc_info_with_ast_id(pc_, RelocInfo reloc_info_with_ast_id(isolate(), pc_, rmode,
rmode, RecordedAstId().ToInt(), NULL);
RecordedAstId().ToInt(),
NULL);
ClearRecordedAstId(); ClearRecordedAstId();
reloc_info_writer.Write(&reloc_info_with_ast_id); reloc_info_writer.Write(&reloc_info_with_ast_id);
} else { } else {
......
...@@ -2323,6 +2323,7 @@ void Assembler::GrowBuffer(int needed) { ...@@ -2323,6 +2323,7 @@ void Assembler::GrowBuffer(int needed) {
// Set up new buffer. // Set up new buffer.
desc.buffer = NewArray<byte>(desc.buffer_size); desc.buffer = NewArray<byte>(desc.buffer_size);
desc.origin = this;
desc.instr_size = pc_offset(); desc.instr_size = pc_offset();
desc.reloc_size = (buffer_ + buffer_size_) - reloc_info_writer.pos(); desc.reloc_size = (buffer_ + buffer_size_) - reloc_info_writer.pos();
...@@ -2401,7 +2402,7 @@ void Assembler::EmitRelocations() { ...@@ -2401,7 +2402,7 @@ void Assembler::EmitRelocations() {
RelocInfo::Mode rmode = it->rmode(); RelocInfo::Mode rmode = it->rmode();
Address pc = buffer_ + it->position(); Address pc = buffer_ + it->position();
Code* code = NULL; Code* code = NULL;
RelocInfo rinfo(pc, rmode, it->data(), code); RelocInfo rinfo(isolate(), pc, rmode, it->data(), code);
// Fix up internal references now that they are guaranteed to be bound. // Fix up internal references now that they are guaranteed to be bound.
if (RelocInfo::IsInternalReference(rmode)) { if (RelocInfo::IsInternalReference(rmode)) {
......
...@@ -404,7 +404,7 @@ void RelocInfo::set_target_object(Object* target, ...@@ -404,7 +404,7 @@ void RelocInfo::set_target_object(Object* target,
DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
Memory::Object_at(pc_) = target; Memory::Object_at(pc_) = target;
if (icache_flush_mode != SKIP_ICACHE_FLUSH) { if (icache_flush_mode != SKIP_ICACHE_FLUSH) {
Assembler::FlushICacheWithoutIsolate(pc_, sizeof(Address)); Assembler::FlushICache(isolate_, pc_, sizeof(Address));
} }
if (write_barrier_mode == UPDATE_WRITE_BARRIER && if (write_barrier_mode == UPDATE_WRITE_BARRIER &&
host() != NULL && host() != NULL &&
...@@ -451,7 +451,7 @@ void RelocInfo::set_target_cell(Cell* cell, ...@@ -451,7 +451,7 @@ void RelocInfo::set_target_cell(Cell* cell,
Address address = cell->address() + Cell::kValueOffset; Address address = cell->address() + Cell::kValueOffset;
Memory::Address_at(pc_) = address; Memory::Address_at(pc_) = address;
if (icache_flush_mode != SKIP_ICACHE_FLUSH) { if (icache_flush_mode != SKIP_ICACHE_FLUSH) {
Assembler::FlushICacheWithoutIsolate(pc_, sizeof(Address)); Assembler::FlushICache(isolate_, pc_, sizeof(Address));
} }
if (write_barrier_mode == UPDATE_WRITE_BARRIER && if (write_barrier_mode == UPDATE_WRITE_BARRIER &&
host() != NULL) { host() != NULL) {
...@@ -527,8 +527,9 @@ void RelocInfo::set_debug_call_address(Address target) { ...@@ -527,8 +527,9 @@ void RelocInfo::set_debug_call_address(Address target) {
DCHECK(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()); DCHECK(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence());
Memory::Address_at(pc_ + Assembler::kPatchDebugBreakSlotAddressOffset) = Memory::Address_at(pc_ + Assembler::kPatchDebugBreakSlotAddressOffset) =
target; target;
Assembler::FlushICacheWithoutIsolate( Assembler::FlushICache(isolate_,
pc_ + Assembler::kPatchDebugBreakSlotAddressOffset, sizeof(Address)); pc_ + Assembler::kPatchDebugBreakSlotAddressOffset,
sizeof(Address));
if (host() != NULL) { if (host() != NULL) {
Object* target_code = Code::GetCodeFromTargetAddress(target); Object* target_code = Code::GetCodeFromTargetAddress(target);
host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(
...@@ -541,7 +542,7 @@ void RelocInfo::Visit(Isolate* isolate, ObjectVisitor* visitor) { ...@@ -541,7 +542,7 @@ void RelocInfo::Visit(Isolate* isolate, ObjectVisitor* visitor) {
RelocInfo::Mode mode = rmode(); RelocInfo::Mode mode = rmode();
if (mode == RelocInfo::EMBEDDED_OBJECT) { if (mode == RelocInfo::EMBEDDED_OBJECT) {
visitor->VisitEmbeddedPointer(this); visitor->VisitEmbeddedPointer(this);
Assembler::FlushICacheWithoutIsolate(pc_, sizeof(Address)); Assembler::FlushICache(isolate, pc_, sizeof(Address));
} else if (RelocInfo::IsCodeTarget(mode)) { } else if (RelocInfo::IsCodeTarget(mode)) {
visitor->VisitCodeTarget(this); visitor->VisitCodeTarget(this);
} else if (mode == RelocInfo::CELL) { } else if (mode == RelocInfo::CELL) {
......
...@@ -389,6 +389,7 @@ void Assembler::GrowBuffer() { ...@@ -389,6 +389,7 @@ void Assembler::GrowBuffer() {
// Set up new buffer. // Set up new buffer.
desc.buffer = NewArray<byte>(desc.buffer_size); desc.buffer = NewArray<byte>(desc.buffer_size);
desc.origin = this;
desc.instr_size = pc_offset(); desc.instr_size = pc_offset();
desc.reloc_size = desc.reloc_size =
static_cast<int>((buffer_ + buffer_size_) - (reloc_info_writer.pos())); static_cast<int>((buffer_ + buffer_size_) - (reloc_info_writer.pos()));
...@@ -4116,7 +4117,7 @@ void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { ...@@ -4116,7 +4117,7 @@ void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) {
// Don't record psuedo relocation info for code age sequence mode. // Don't record psuedo relocation info for code age sequence mode.
return; return;
} }
RelocInfo rinfo(pc_, rmode, data, NULL); RelocInfo rinfo(isolate(), pc_, rmode, data, NULL);
reloc_info_writer.Write(&rinfo); reloc_info_writer.Write(&rinfo);
} }
......
...@@ -134,7 +134,7 @@ void RelocInfo::set_target_object(Object* target, ...@@ -134,7 +134,7 @@ void RelocInfo::set_target_object(Object* target,
DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
Memory::Object_at(pc_) = target; Memory::Object_at(pc_) = target;
if (icache_flush_mode != SKIP_ICACHE_FLUSH) { if (icache_flush_mode != SKIP_ICACHE_FLUSH) {
Assembler::FlushICacheWithoutIsolate(pc_, sizeof(Address)); Assembler::FlushICache(isolate_, pc_, sizeof(Address));
} }
if (write_barrier_mode == UPDATE_WRITE_BARRIER && if (write_barrier_mode == UPDATE_WRITE_BARRIER &&
host() != NULL && host() != NULL &&
...@@ -200,7 +200,7 @@ void RelocInfo::set_target_cell(Cell* cell, ...@@ -200,7 +200,7 @@ void RelocInfo::set_target_cell(Cell* cell,
Address address = cell->address() + Cell::kValueOffset; Address address = cell->address() + Cell::kValueOffset;
Memory::Address_at(pc_) = address; Memory::Address_at(pc_) = address;
if (icache_flush_mode != SKIP_ICACHE_FLUSH) { if (icache_flush_mode != SKIP_ICACHE_FLUSH) {
Assembler::FlushICacheWithoutIsolate(pc_, sizeof(Address)); Assembler::FlushICache(isolate_, pc_, sizeof(Address));
} }
if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL) { if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL) {
// TODO(1550) We are passing NULL as a slot because cell can never be on // TODO(1550) We are passing NULL as a slot because cell can never be on
......
...@@ -1945,6 +1945,7 @@ void Assembler::GrowBuffer() { ...@@ -1945,6 +1945,7 @@ void Assembler::GrowBuffer() {
// Set up new buffer. // Set up new buffer.
desc.buffer = NewArray<byte>(desc.buffer_size); desc.buffer = NewArray<byte>(desc.buffer_size);
desc.origin = this;
desc.instr_size = pc_offset(); desc.instr_size = pc_offset();
desc.reloc_size = (buffer_ + buffer_size_) - (reloc_info_writer.pos()); desc.reloc_size = (buffer_ + buffer_size_) - (reloc_info_writer.pos());
...@@ -2080,7 +2081,7 @@ void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { ...@@ -2080,7 +2081,7 @@ void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) {
!serializer_enabled() && !emit_debug_code()) { !serializer_enabled() && !emit_debug_code()) {
return; return;
} }
RelocInfo rinfo(pc_, rmode, data, NULL); RelocInfo rinfo(isolate(), pc_, rmode, data, NULL);
reloc_info_writer.Write(&rinfo); reloc_info_writer.Write(&rinfo);
} }
......
...@@ -75,7 +75,7 @@ void Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(Handle<Code> code) { ...@@ -75,7 +75,7 @@ void Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(Handle<Code> code) {
new_reloc->GetDataStartAddress() + padding, 0); new_reloc->GetDataStartAddress() + padding, 0);
intptr_t comment_string intptr_t comment_string
= reinterpret_cast<intptr_t>(RelocInfo::kFillerCommentString); = reinterpret_cast<intptr_t>(RelocInfo::kFillerCommentString);
RelocInfo rinfo(0, RelocInfo::COMMENT, comment_string, NULL); RelocInfo rinfo(isolate, 0, RelocInfo::COMMENT, comment_string, NULL);
for (int i = 0; i < additional_comments; ++i) { for (int i = 0; i < additional_comments; ++i) {
#ifdef DEBUG #ifdef DEBUG
byte* pos_before = reloc_info_writer.pos(); byte* pos_before = reloc_info_writer.pos();
...@@ -142,10 +142,9 @@ void Deoptimizer::PatchCodeForDeoptimization(Isolate* isolate, Code* code) { ...@@ -142,10 +142,9 @@ void Deoptimizer::PatchCodeForDeoptimization(Isolate* isolate, Code* code) {
Address deopt_entry = GetDeoptimizationEntry(isolate, i, LAZY); Address deopt_entry = GetDeoptimizationEntry(isolate, i, LAZY);
patcher.masm()->call(deopt_entry, RelocInfo::NONE32); patcher.masm()->call(deopt_entry, RelocInfo::NONE32);
// We use RUNTIME_ENTRY for deoptimization bailouts. // We use RUNTIME_ENTRY for deoptimization bailouts.
RelocInfo rinfo(call_address + 1, // 1 after the call opcode. RelocInfo rinfo(isolate, call_address + 1, // 1 after the call opcode.
RelocInfo::RUNTIME_ENTRY, RelocInfo::RUNTIME_ENTRY,
reinterpret_cast<intptr_t>(deopt_entry), reinterpret_cast<intptr_t>(deopt_entry), NULL);
NULL);
reloc_info_writer.Write(&rinfo); reloc_info_writer.Write(&rinfo);
DCHECK_GE(reloc_info_writer.pos(), DCHECK_GE(reloc_info_writer.pos(),
reloc_info->address() + ByteArray::kHeaderSize); reloc_info->address() + ByteArray::kHeaderSize);
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#define V8_IMMINENT_DEPRECATION_WARNINGS #define V8_IMMINENT_DEPRECATION_WARNINGS
#include "src/assembler.h" #include "src/assembler.h"
#include "src/macro-assembler.h"
#include "test/cctest/cctest.h" #include "test/cctest/cctest.h"
namespace v8 { namespace v8 {
...@@ -36,7 +37,7 @@ namespace internal { ...@@ -36,7 +37,7 @@ namespace internal {
static void WriteRinfo(RelocInfoWriter* writer, static void WriteRinfo(RelocInfoWriter* writer,
byte* pc, RelocInfo::Mode mode, intptr_t data) { byte* pc, RelocInfo::Mode mode, intptr_t data) {
RelocInfo rinfo(pc, mode, data, NULL); RelocInfo rinfo(CcTest::i_isolate(), pc, mode, data, NULL);
writer->Write(&rinfo); writer->Write(&rinfo);
} }
...@@ -44,6 +45,7 @@ static void WriteRinfo(RelocInfoWriter* writer, ...@@ -44,6 +45,7 @@ static void WriteRinfo(RelocInfoWriter* writer,
// Tests that writing both types of positions and then reading either // Tests that writing both types of positions and then reading either
// or both works as expected. // or both works as expected.
TEST(Positions) { TEST(Positions) {
CcTest::InitializeVM();
const int code_size = 10 * KB; const int code_size = 10 * KB;
int relocation_info_size = 10 * KB; int relocation_info_size = 10 * KB;
const int buffer_size = code_size + relocation_info_size; const int buffer_size = code_size + relocation_info_size;
...@@ -68,8 +70,9 @@ TEST(Positions) { ...@@ -68,8 +70,9 @@ TEST(Positions) {
writer.Finish(); writer.Finish();
relocation_info_size = static_cast<int>(buffer_end - writer.pos()); relocation_info_size = static_cast<int>(buffer_end - writer.pos());
CodeDesc desc = {buffer.get(), buffer_size, code_size, relocation_info_size, MacroAssembler assm(CcTest::i_isolate(), nullptr, 0, CodeObjectRequired::kNo);
0, NULL}; CodeDesc desc = {buffer.get(), buffer_size, code_size,
relocation_info_size, 0, &assm};
// Read only (non-statement) positions. // Read only (non-statement) positions.
{ {
......
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