Commit d96dc075 authored by whesse@chromium.org's avatar whesse@chromium.org

Add AST ID to RelocInfo for type-recording ICs. Changes 7644 and 7632, combined.

BUG=
TEST=

Review URL: http://codereview.chromium.org/6902066

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7694 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 7ba01a83
......@@ -315,6 +315,7 @@ Assembler::Assembler(Isolate* arg_isolate, void* buffer, int buffer_size)
no_const_pool_before_ = 0;
last_const_pool_end_ = 0;
last_bound_pos_ = 0;
ast_id_for_reloc_info_ = kNoASTId;
}
......@@ -2722,7 +2723,14 @@ void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) {
}
}
ASSERT(buffer_space() >= kMaxRelocSize); // too late to grow buffer here
reloc_info_writer.Write(&rinfo);
if (rmode == RelocInfo::CODE_TARGET_WITH_ID) {
ASSERT(ast_id_for_reloc_info_ != kNoASTId);
RelocInfo reloc_info_with_ast_id(pc_, rmode, ast_id_for_reloc_info_);
ast_id_for_reloc_info_ = kNoASTId;
reloc_info_writer.Write(&reloc_info_with_ast_id);
} else {
reloc_info_writer.Write(&rinfo);
}
}
}
......
......@@ -1167,6 +1167,10 @@ class Assembler : public AssemblerBase {
// Mark address of a debug break slot.
void RecordDebugBreakSlot();
// Record the AST id of the CallIC being compiled, so that it can be placed
// in the relocation information.
void RecordAstId(unsigned ast_id) { ast_id_for_reloc_info_ = ast_id; }
// Record a comment relocation entry that can be used by a disassembler.
// Use --code-comments to enable.
void RecordComment(const char* msg);
......@@ -1224,6 +1228,11 @@ class Assembler : public AssemblerBase {
void CheckConstPool(bool force_emit, bool require_jump);
protected:
// Relocation for a type-recording IC has the AST id added to it. This
// member variable is a way to pass the information from the call site to
// the relocation info.
unsigned ast_id_for_reloc_info_;
bool emit_debug_code() const { return emit_debug_code_; }
int buffer_space() const { return reloc_info_writer.pos() - pc_; }
......
This diff is collapsed.
......@@ -148,8 +148,9 @@ int MacroAssembler::CallSize(
}
void MacroAssembler::Call(
intptr_t target, RelocInfo::Mode rmode, Condition cond) {
void MacroAssembler::Call(intptr_t target,
RelocInfo::Mode rmode,
Condition cond) {
// Block constant pool for the call instruction sequence.
BlockConstPoolScope block_const_pool(this);
#ifdef DEBUG
......@@ -214,8 +215,31 @@ int MacroAssembler::CallSize(
}
void MacroAssembler::Call(
Handle<Code> code, RelocInfo::Mode rmode, Condition cond) {
void MacroAssembler::CallWithAstId(Handle<Code> code,
RelocInfo::Mode rmode,
unsigned ast_id,
Condition cond) {
#ifdef DEBUG
int pre_position = pc_offset();
#endif
ASSERT(rmode == RelocInfo::CODE_TARGET_WITH_ID);
ASSERT(ast_id != kNoASTId);
ASSERT(ast_id_for_reloc_info_ == kNoASTId);
ast_id_for_reloc_info_ = ast_id;
// 'code' is always generated ARM code, never THUMB code
Call(reinterpret_cast<intptr_t>(code.location()), rmode, cond);
#ifdef DEBUG
int post_position = pc_offset();
CHECK_EQ(pre_position + CallSize(code, rmode, cond), post_position);
#endif
}
void MacroAssembler::Call(Handle<Code> code,
RelocInfo::Mode rmode,
Condition cond) {
#ifdef DEBUG
int pre_position = pc_offset();
#endif
......
......@@ -105,7 +105,13 @@ class MacroAssembler: public Assembler {
int CallSize(byte* target, RelocInfo::Mode rmode, Condition cond = al);
void Call(byte* target, RelocInfo::Mode rmode, Condition cond = al);
int CallSize(Handle<Code> code, RelocInfo::Mode rmode, Condition cond = al);
void Call(Handle<Code> code, RelocInfo::Mode rmode, Condition cond = al);
void Call(Handle<Code> code,
RelocInfo::Mode rmode,
Condition cond = al);
void CallWithAstId(Handle<Code> code,
RelocInfo::Mode rmode,
unsigned ast_id,
Condition cond = al);
void Ret(Condition cond = al);
// Emit code to discard a non-negative number of pointer-sized elements
......@@ -985,7 +991,9 @@ class MacroAssembler: public Assembler {
void Jump(intptr_t target, RelocInfo::Mode rmode, Condition cond = al);
int CallSize(intptr_t target, RelocInfo::Mode rmode, Condition cond = al);
void Call(intptr_t target, RelocInfo::Mode rmode, Condition cond = al);
void Call(intptr_t target,
RelocInfo::Mode rmode,
Condition cond = al);
// Helper functions for generating invokes.
void InvokePrologue(const ParameterCount& expected,
......
This diff is collapsed.
......@@ -42,7 +42,7 @@
namespace v8 {
namespace internal {
const unsigned kNoASTId = -1;
// -----------------------------------------------------------------------------
// Platform independent assembler base class.
......@@ -209,10 +209,11 @@ class RelocInfo BASE_EMBEDDED {
enum Mode {
// Please note the order is important (see IsCodeTarget, IsGCRelocMode).
CODE_TARGET, // Code target which is not any of the above.
CODE_TARGET_WITH_ID,
CONSTRUCT_CALL, // code target that is a call to a JavaScript constructor.
CODE_TARGET_CONTEXT, // Code target used for contextual loads and stores.
DEBUG_BREAK, // Code target for the debugger statement.
CODE_TARGET, // Code target which is not any of the above.
EMBEDDED_OBJECT,
GLOBAL_PROPERTY_CELL,
......@@ -228,10 +229,12 @@ class RelocInfo BASE_EMBEDDED {
// add more as needed
// Pseudo-types
NUMBER_OF_MODES, // must be no greater than 14 - see RelocInfoWriter
NUMBER_OF_MODES, // There are at most 14 modes with noncompact encoding.
NONE, // never recorded
LAST_CODE_ENUM = CODE_TARGET,
LAST_GCED_ENUM = GLOBAL_PROPERTY_CELL
LAST_CODE_ENUM = DEBUG_BREAK,
LAST_GCED_ENUM = GLOBAL_PROPERTY_CELL,
// Modes <= LAST_COMPACT_ENUM are guaranteed to have compact encoding.
LAST_COMPACT_ENUM = CODE_TARGET_WITH_ID
};
......@@ -361,7 +364,8 @@ class RelocInfo BASE_EMBEDDED {
static const int kCodeTargetMask = (1 << (LAST_CODE_ENUM + 1)) - 1;
static const int kPositionMask = 1 << POSITION | 1 << STATEMENT_POSITION;
static const int kDebugMask = kPositionMask | 1 << COMMENT;
static const int kDataMask =
(1 << CODE_TARGET_WITH_ID) | kPositionMask | (1 << COMMENT);
static const int kApplyMask; // Modes affected by apply. Depends on arch.
private:
......@@ -380,9 +384,14 @@ class RelocInfo BASE_EMBEDDED {
// lower addresses.
class RelocInfoWriter BASE_EMBEDDED {
public:
RelocInfoWriter() : pos_(NULL), last_pc_(NULL), last_data_(0) {}
RelocInfoWriter(byte* pos, byte* pc) : pos_(pos), last_pc_(pc),
last_data_(0) {}
RelocInfoWriter() : pos_(NULL),
last_pc_(NULL),
last_id_(0),
last_position_(0) {}
RelocInfoWriter(byte* pos, byte* pc) : pos_(pos),
last_pc_(pc),
last_id_(0),
last_position_(0) {}
byte* pos() const { return pos_; }
byte* last_pc() const { return last_pc_; }
......@@ -407,13 +416,15 @@ class RelocInfoWriter BASE_EMBEDDED {
inline uint32_t WriteVariableLengthPCJump(uint32_t pc_delta);
inline void WriteTaggedPC(uint32_t pc_delta, int tag);
inline void WriteExtraTaggedPC(uint32_t pc_delta, int extra_tag);
inline void WriteExtraTaggedIntData(int data_delta, int top_tag);
inline void WriteExtraTaggedData(intptr_t data_delta, int top_tag);
inline void WriteTaggedData(intptr_t data_delta, int tag);
inline void WriteExtraTag(int extra_tag, int top_tag);
byte* pos_;
byte* last_pc_;
intptr_t last_data_;
int last_id_;
int last_position_;
DISALLOW_COPY_AND_ASSIGN(RelocInfoWriter);
};
......@@ -455,12 +466,13 @@ class RelocIterator: public Malloced {
int GetTopTag();
void ReadTaggedPC();
void AdvanceReadPC();
void AdvanceReadId();
void AdvanceReadPosition();
void AdvanceReadData();
void AdvanceReadVariableLengthPCJump();
int GetPositionTypeTag();
void ReadTaggedData();
static RelocInfo::Mode DebugInfoModeFromTag(int tag);
int GetLocatableTypeTag();
void ReadTaggedId();
void ReadTaggedPosition();
// If the given mode is wanted, set it in rinfo_ and return true.
// Else return false. Used for efficiently skipping unwanted modes.
......@@ -473,6 +485,8 @@ class RelocIterator: public Malloced {
RelocInfo rinfo_;
bool done_;
int mode_mask_;
int last_id_;
int last_position_;
DISALLOW_COPY_AND_ASSIGN(RelocIterator);
};
......
......@@ -1147,6 +1147,7 @@ CaseClause::CaseClause(Expression* label,
statements_(statements),
position_(pos),
compare_type_(NONE),
compare_id_(AstNode::GetNextId()),
entry_id_(AstNode::GetNextId()) {
}
......
......@@ -661,6 +661,7 @@ class CaseClause: public ZoneObject {
void set_position(int pos) { position_ = pos; }
int EntryId() { return entry_id_; }
int CompareId() { return compare_id_; }
// Type feedback information.
void RecordTypeFeedback(TypeFeedbackOracle* oracle);
......@@ -674,6 +675,7 @@ class CaseClause: public ZoneObject {
int position_;
enum CompareTypeFeedback { NONE, SMI_ONLY, OBJECT_ONLY };
CompareTypeFeedback compare_type_;
int compare_id_;
int entry_id_;
};
......
......@@ -282,6 +282,9 @@ static int DecodeIt(FILE* f,
} else {
out.AddFormatted(" %s", Code::Kind2String(kind));
}
if (rmode == RelocInfo::CODE_TARGET_WITH_ID) {
out.AddFormatted(" (id = %d)", static_cast<int>(relocinfo.data()));
}
} else if (rmode == RelocInfo::RUNTIME_ENTRY &&
Isolate::Current()->deoptimizer_data() != NULL) {
// A runtime entry reloinfo might be a deoptimization bailout.
......
......@@ -744,7 +744,7 @@ void FullCodeGenerator::VisitBinaryOperation(BinaryOperation* expr) {
if (ShouldInlineSmiCase(op)) {
EmitInlineSmiBinaryOp(expr, op, mode, left, right);
} else {
EmitBinaryOp(op, mode);
EmitBinaryOp(expr, op, mode);
}
break;
}
......
// Copyright 2010 the V8 project authors. All rights reserved.
// Copyright 2011 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
......@@ -445,12 +445,13 @@ class FullCodeGenerator: public AstVisitor {
// Apply the compound assignment operator. Expects the left operand on top
// of the stack and the right one in the accumulator.
void EmitBinaryOp(Token::Value op,
void EmitBinaryOp(BinaryOperation* expr,
Token::Value op,
OverwriteMode mode);
// Helper functions for generating inlined smi code for certain
// binary operations.
void EmitInlineSmiBinaryOp(Expression* expr,
void EmitInlineSmiBinaryOp(BinaryOperation* expr,
Token::Value op,
OverwriteMode mode,
Expression* left,
......@@ -512,12 +513,16 @@ class FullCodeGenerator: public AstVisitor {
static Register context_register();
// Helper for calling an IC stub.
void EmitCallIC(Handle<Code> ic, RelocInfo::Mode mode);
void EmitCallIC(Handle<Code> ic,
RelocInfo::Mode mode,
unsigned ast_id);
// Calling an IC stub with a patch site. Passing NULL for patch_site
// or non NULL patch_site which is not activated indicates no inlined smi code
// and emits a nop after the IC call.
void EmitCallIC(Handle<Code> ic, JumpPatchSite* patch_site);
void EmitCallIC(Handle<Code> ic,
JumpPatchSite* patch_site,
unsigned ast_id);
// Set fields in the stack frame. Offsets are the frame pointer relative
// offsets defined in, e.g., StandardFrameConstants.
......
......@@ -30,7 +30,7 @@
// The original source code covered by the above license above has been
// modified significantly by Google Inc.
// Copyright 2006-2008 the V8 project authors. All rights reserved.
// Copyright 2011 the V8 project authors. All rights reserved.
// A light-weight IA32 Assembler.
......@@ -311,8 +311,12 @@ void Assembler::emit(Handle<Object> handle) {
}
void Assembler::emit(uint32_t x, RelocInfo::Mode rmode) {
if (rmode != RelocInfo::NONE) RecordRelocInfo(rmode);
void Assembler::emit(uint32_t x, RelocInfo::Mode rmode, unsigned id) {
if (rmode == RelocInfo::CODE_TARGET && id != kNoASTId) {
RecordRelocInfo(RelocInfo::CODE_TARGET_WITH_ID, static_cast<intptr_t>(id));
} else if (rmode != RelocInfo::NONE) {
RecordRelocInfo(rmode);
}
emit(x);
}
......
......@@ -1589,13 +1589,15 @@ void Assembler::call(const Operand& adr) {
}
void Assembler::call(Handle<Code> code, RelocInfo::Mode rmode) {
void Assembler::call(Handle<Code> code,
RelocInfo::Mode rmode,
unsigned ast_id) {
positions_recorder()->WriteRecordedPositions();
EnsureSpace ensure_space(this);
last_pc_ = pc_;
ASSERT(RelocInfo::IsCodeTarget(rmode));
EMIT(0xE8);
emit(reinterpret_cast<intptr_t>(code.location()), rmode);
emit(reinterpret_cast<intptr_t>(code.location()), rmode, ast_id);
}
......
......@@ -848,7 +848,9 @@ class Assembler : public AssemblerBase {
void call(Label* L);
void call(byte* entry, RelocInfo::Mode rmode);
void call(const Operand& adr);
void call(Handle<Code> code, RelocInfo::Mode rmode);
void call(Handle<Code> code,
RelocInfo::Mode rmode,
unsigned ast_id = kNoASTId);
// Jumps
void jmp(Label* L); // unconditional jump to L
......@@ -1070,7 +1072,9 @@ class Assembler : public AssemblerBase {
void GrowBuffer();
inline void emit(uint32_t x);
inline void emit(Handle<Object> handle);
inline void emit(uint32_t x, RelocInfo::Mode rmode);
inline void emit(uint32_t x,
RelocInfo::Mode rmode,
unsigned ast_id = kNoASTId);
inline void emit(const Immediate& x);
inline void emit_w(const Immediate& x);
......
This diff is collapsed.
......@@ -1104,9 +1104,9 @@ void MacroAssembler::TryGetFunctionPrototype(Register function,
}
void MacroAssembler::CallStub(CodeStub* stub) {
void MacroAssembler::CallStub(CodeStub* stub, unsigned ast_id) {
ASSERT(allow_stub_calls()); // Calls are not allowed in some stubs.
call(stub->GetCode(), RelocInfo::CODE_TARGET);
call(stub->GetCode(), RelocInfo::CODE_TARGET, ast_id);
}
......
......@@ -452,7 +452,7 @@ class MacroAssembler: public Assembler {
// Runtime calls
// Call a code stub. Generate the code if necessary.
void CallStub(CodeStub* stub);
void CallStub(CodeStub* stub, unsigned ast_id = kNoASTId);
// Call a code stub and return the code object called. Try to generate
// the code if necessary. Do not perform a GC but instead return a retry
......
This diff is collapsed.
......@@ -36,18 +36,18 @@ namespace v8 {
namespace internal {
// Unknown
// | |
// | \--------------|
// Primitive Non-primitive
// | \--------| |
// Number String |
// / | | |
// Double Integer32 | /
// | | / /
// | Smi / /
// | | / /
// | | / /
// Uninitialized.--/
// | \____________
// | |
// Primitive Non-primitive
// | \_______ |
// | | |
// Number String |
// / \ | |
// Double Integer32 | /
// | | / /
// | Smi / /
// | | / __/
// Uninitialized.
class TypeInfo {
public:
......@@ -263,21 +263,21 @@ class TypeFeedbackOracle BASE_EMBEDDED {
TypeInfo SwitchType(CaseClause* clause);
private:
ZoneMapList* CollectReceiverTypes(int position,
ZoneMapList* CollectReceiverTypes(unsigned ast_id,
Handle<String> name,
Code::Flags flags);
void SetInfo(int position, Object* target);
void SetInfo(unsigned ast_id, Object* target);
void PopulateMap(Handle<Code> code);
void CollectPositions(Code* code,
List<int>* code_positions,
List<int>* source_positions);
void CollectIds(Code* code,
List<int>* code_positions,
List<unsigned>* ast_ids);
// Returns an element from the backing store. Returns undefined if
// there is no information.
Handle<Object> GetInfo(int pos);
Handle<Object> GetInfo(unsigned ast_id);
Handle<Context> global_context_;
Handle<NumberDictionary> dictionary_;
......
......@@ -61,9 +61,15 @@ void Assembler::emitw(uint16_t x) {
}
void Assembler::emit_code_target(Handle<Code> target, RelocInfo::Mode rmode) {
void Assembler::emit_code_target(Handle<Code> target,
RelocInfo::Mode rmode,
unsigned ast_id) {
ASSERT(RelocInfo::IsCodeTarget(rmode));
RecordRelocInfo(rmode);
if (rmode == RelocInfo::CODE_TARGET && ast_id != kNoASTId) {
RecordRelocInfo(RelocInfo::CODE_TARGET_WITH_ID, ast_id);
} else {
RecordRelocInfo(rmode);
}
int current = code_targets_.length();
if (current > 0 && code_targets_.last().is_identical_to(target)) {
// Optimization if we keep jumping to the same code target.
......
......@@ -869,12 +869,14 @@ void Assembler::call(Label* L) {
}
void Assembler::call(Handle<Code> target, RelocInfo::Mode rmode) {
void Assembler::call(Handle<Code> target,
RelocInfo::Mode rmode,
unsigned ast_id) {
positions_recorder()->WriteRecordedPositions();
EnsureSpace ensure_space(this);
// 1110 1000 #32-bit disp.
emit(0xE8);
emit_code_target(target, rmode);
emit_code_target(target, rmode, ast_id);
}
......
......@@ -1183,7 +1183,9 @@ class Assembler : public AssemblerBase {
// Calls
// Call near relative 32-bit displacement, relative to next instruction.
void call(Label* L);
void call(Handle<Code> target, RelocInfo::Mode rmode);
void call(Handle<Code> target,
RelocInfo::Mode rmode,
unsigned ast_id = kNoASTId);
// Calls directly to the given address using a relative offset.
// Should only ever be used in Code objects for calls within the
......@@ -1427,7 +1429,9 @@ class Assembler : public AssemblerBase {
inline void emitl(uint32_t x);
inline void emitq(uint64_t x, RelocInfo::Mode rmode);
inline void emitw(uint16_t x);
inline void emit_code_target(Handle<Code> target, RelocInfo::Mode rmode);
inline void emit_code_target(Handle<Code> target,
RelocInfo::Mode rmode,
unsigned ast_id = kNoASTId);
void emit(Immediate x) { emitl(x.value_); }
// Emits a REX prefix that encodes a 64-bit operand size and
......
This diff is collapsed.
......@@ -425,9 +425,9 @@ void MacroAssembler::Abort(const char* msg) {
}
void MacroAssembler::CallStub(CodeStub* stub) {
void MacroAssembler::CallStub(CodeStub* stub, unsigned ast_id) {
ASSERT(allow_stub_calls()); // calls are not allowed in some stubs
Call(stub->GetCode(), RelocInfo::CODE_TARGET);
Call(stub->GetCode(), RelocInfo::CODE_TARGET, ast_id);
}
......@@ -1610,12 +1610,14 @@ void MacroAssembler::Call(Address destination, RelocInfo::Mode rmode) {
}
void MacroAssembler::Call(Handle<Code> code_object, RelocInfo::Mode rmode) {
void MacroAssembler::Call(Handle<Code> code_object,
RelocInfo::Mode rmode,
unsigned ast_id) {
#ifdef DEBUG
int end_position = pc_offset() + CallSize(code_object);
#endif
ASSERT(RelocInfo::IsCodeTarget(rmode));
call(code_object, rmode);
call(code_object, rmode, ast_id);
#ifdef DEBUG
CHECK_EQ(end_position, pc_offset());
#endif
......
......@@ -692,7 +692,9 @@ class MacroAssembler: public Assembler {
void Call(Address destination, RelocInfo::Mode rmode);
void Call(ExternalReference ext);
void Call(Handle<Code> code_object, RelocInfo::Mode rmode);
void Call(Handle<Code> code_object,
RelocInfo::Mode rmode,
unsigned ast_id = kNoASTId);
// The size of the code generated for different call instructions.
int CallSize(Address destination, RelocInfo::Mode rmode) {
......@@ -932,7 +934,7 @@ class MacroAssembler: public Assembler {
// Runtime calls
// Call a code stub.
void CallStub(CodeStub* stub);
void CallStub(CodeStub* stub, unsigned ast_id = kNoASTId);
// Call a code stub and return the code object called. Try to generate
// the code if necessary. Do not perform a GC but instead return a retry
......
......@@ -501,7 +501,11 @@ void CheckDebugBreakFunction(DebugLocalContext* env,
CHECK(Debug::HasDebugInfo(shared));
TestBreakLocationIterator it1(Debug::GetDebugInfo(shared));
it1.FindBreakLocationFromPosition(position);
CHECK_EQ(mode, it1.it()->rinfo()->rmode());
v8::internal::RelocInfo::Mode actual_mode = it1.it()->rinfo()->rmode();
if (actual_mode == v8::internal::RelocInfo::CODE_TARGET_WITH_ID) {
actual_mode = v8::internal::RelocInfo::CODE_TARGET;
}
CHECK_EQ(mode, actual_mode);
if (mode != v8::internal::RelocInfo::JS_RETURN) {
CHECK_EQ(debug_break,
Code::GetCodeFromTargetAddress(it1.it()->rinfo()->target_address()));
......@@ -516,7 +520,11 @@ void CheckDebugBreakFunction(DebugLocalContext* env,
CHECK(debug->EnsureDebugInfo(shared));
TestBreakLocationIterator it2(Debug::GetDebugInfo(shared));
it2.FindBreakLocationFromPosition(position);
CHECK_EQ(mode, it2.it()->rinfo()->rmode());
actual_mode = it2.it()->rinfo()->rmode();
if (actual_mode == v8::internal::RelocInfo::CODE_TARGET_WITH_ID) {
actual_mode = v8::internal::RelocInfo::CODE_TARGET;
}
CHECK_EQ(mode, actual_mode);
if (mode == v8::internal::RelocInfo::JS_RETURN) {
CHECK(!Debug::IsDebugBreakAtReturn(it2.it()->rinfo()));
}
......
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