Fix lint issues.
Review URL: http://codereview.chromium.org/3144 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@344 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
2816e8a899
commit
914611056a
@ -2018,6 +2018,7 @@ void Assembler::emit_farith(int b1, int b2, int i) {
|
||||
EMIT(b2 + i);
|
||||
}
|
||||
|
||||
|
||||
void Assembler::dd(uint32_t data, RelocMode reloc_info) {
|
||||
EnsureSpace ensure_space(this);
|
||||
emit(data, reloc_info);
|
||||
@ -2036,9 +2037,10 @@ void Assembler::RecordRelocInfo(RelocMode rmode, intptr_t data) {
|
||||
reloc_info_writer.Write(&rinfo);
|
||||
}
|
||||
|
||||
void Assembler::WriteInternalReference(int position, Label &bound_label) {
|
||||
void Assembler::WriteInternalReference(int position, const Label& bound_label) {
|
||||
ASSERT(bound_label.is_bound());
|
||||
ASSERT(0 <= position && position + (int)sizeof(uint32_t) <= pc_offset());
|
||||
ASSERT(0 <= position);
|
||||
ASSERT(position + static_cast<int>(sizeof(uint32_t)) <= pc_offset());
|
||||
ASSERT(long_at(position) == 0); // only initialize once!
|
||||
|
||||
uint32_t label_loc = reinterpret_cast<uint32_t>(addr_at(bound_label.pos()));
|
||||
|
@ -683,7 +683,7 @@ class Assembler : public Malloced {
|
||||
// Writes the absolute address of a bound label at the given position in
|
||||
// the generated code. That positions should have the relocation mode
|
||||
// internal_reference!
|
||||
void WriteInternalReference(int position, Label &bound_label);
|
||||
void WriteInternalReference(int position, const Label& bound_label);
|
||||
|
||||
int pc_offset() const { return pc_ - buffer_; }
|
||||
int last_statement_position() const { return last_statement_position_; }
|
||||
|
@ -162,7 +162,7 @@ enum RelocMode {
|
||||
|
||||
// add more as needed
|
||||
// Pseudo-types
|
||||
reloc_mode_count, // Must be no greater than 14. See RelocInfoWriter.
|
||||
reloc_mode_count, // must be no greater than 14 - see RelocInfoWriter
|
||||
no_reloc, // never recorded
|
||||
last_code_enum = code_target,
|
||||
last_gced_enum = embedded_string
|
||||
@ -214,14 +214,17 @@ inline bool is_statement_position(RelocMode mode) {
|
||||
return mode == statement_position;
|
||||
}
|
||||
|
||||
|
||||
inline bool is_external_reference(RelocMode mode) {
|
||||
return mode == external_reference;
|
||||
}
|
||||
|
||||
inline bool is_internal_reference(RelocMode mode) {
|
||||
|
||||
inline bool is_internal_reference(RelocMode mode) {
|
||||
return mode == internal_reference;
|
||||
}
|
||||
|
||||
|
||||
// Relocation information consists of the address (pc) of the datum
|
||||
// to which the relocation information applies, the relocation mode
|
||||
// (rmode), and an optional data field. The relocation mode may be
|
||||
|
@ -322,7 +322,7 @@ class Ia32CodeGenerator: public CodeGenerator {
|
||||
static const int kFastSwitchMaxOverheadFactor = 5;
|
||||
|
||||
// Minimal number of switch cases required before we allow jump-table
|
||||
// optimization.
|
||||
// optimization.
|
||||
static const int kFastSwitchMinCaseCount = 5;
|
||||
|
||||
// Create fast switch implementation if all labels are small integers
|
||||
@ -2939,34 +2939,35 @@ void Ia32CodeGenerator::VisitWithExitStatement(WithExitStatement* node) {
|
||||
// be populated later when the adresses of the targets are known
|
||||
void Ia32CodeGenerator::GenerateFastCaseSwitchJumpTable(
|
||||
int min_index, int range, Label *fail_label, Label &table_start) {
|
||||
// Notice: Internal references, used by both the jmp instruction and the
|
||||
// table entries, need to be relocated if the buffer grows. This prevents
|
||||
// the forward use of Labels, since a displacement cannot survive relocation,
|
||||
// and it also cannot safely be distinguished from a real address.
|
||||
// Instead we put in zero-values as placeholders, and fill in the adresses after
|
||||
// the labels have been bound.
|
||||
// Notice: Internal references, used by both the jmp instruction and
|
||||
// the table entries, need to be relocated if the buffer grows. This
|
||||
// prevents the forward use of Labels, since a displacement cannot
|
||||
// survive relocation, and it also cannot safely be distinguished
|
||||
// from a real address. Instead we put in zero-values as
|
||||
// placeholders, and fill in the adresses after the labels have been
|
||||
// bound.
|
||||
|
||||
__ pop(eax); // supposed Smi
|
||||
__ pop(eax); // supposed smi
|
||||
// check range of value, if outside [0..length-1] jump to default/end label.
|
||||
ASSERT(kSmiTagSize == 1 && kSmiTag == 0);
|
||||
if (min_index != 0) {
|
||||
__ sub(Operand(eax), Immediate(min_index * 2)); // Smi subtraction
|
||||
__ sub(Operand(eax), Immediate(min_index * 2)); // smi subtraction
|
||||
}
|
||||
__ test(eax, Immediate(0x80000000 | kSmiTagMask)); // negative or not Smi
|
||||
__ test(eax, Immediate(0x80000000 | kSmiTagMask)); // negative or not smi
|
||||
__ j(not_equal, fail_label, not_taken);
|
||||
__ cmp(eax, range * 2);
|
||||
__ j(greater_equal, fail_label, not_taken);
|
||||
|
||||
__ jmp(Operand(eax, times_2, 0x0, internal_reference)); // 0 is placeholder
|
||||
// calculate address to overwrite later with actual address of table.
|
||||
int32_t jump_table_ref = __ pc_offset() - sizeof(int32_t);
|
||||
|
||||
int32_t jump_table_ref = __ pc_offset() - sizeof(int32_t);
|
||||
|
||||
__ Align(4);
|
||||
__ bind(&table_start);
|
||||
__ WriteInternalReference(jump_table_ref, table_start);
|
||||
|
||||
|
||||
for (int i = 0; i < range; i++) {
|
||||
__ dd(0x0, internal_reference); // table entry, 0 is placeholder
|
||||
__ dd(0x0, internal_reference); // table entry, 0 is placeholder
|
||||
}
|
||||
}
|
||||
|
||||
@ -2994,14 +2995,15 @@ void Ia32CodeGenerator::GenerateFastCaseSwitchStatement(
|
||||
Label* fail_label = (default_index >= 0 ? &(case_labels[default_index])
|
||||
: node->break_target());
|
||||
|
||||
// create array of labels to jump to by index.
|
||||
// set default jump targets everywhere
|
||||
// Create array of labels to jump to by index and set default jump
|
||||
// targets everywhere.
|
||||
for (int i = 0; i < range; i++) {
|
||||
// length => end label
|
||||
case_targets[i] = fail_label;
|
||||
}
|
||||
// overwrite for values of cases:
|
||||
// (reverse order, so that if same label twice, the first one wins)
|
||||
|
||||
// Overwrite for values of cases:
|
||||
// (reverse order, so that if same label twice, the first one wins).
|
||||
for (int i = length-1; i >= 0 ; i--) {
|
||||
CaseClause* clause = cases->at(i);
|
||||
if (!clause->is_default()) {
|
||||
@ -3024,7 +3026,7 @@ void Ia32CodeGenerator::GenerateFastCaseSwitchStatement(
|
||||
|
||||
__ bind(node->break_target());
|
||||
|
||||
// all labels bound now, so we can populate the table with the
|
||||
// All labels bound now, so we can populate the table with the
|
||||
// correct addresses.
|
||||
PopulateFastCaseSwitchJumpTable(table_start, case_targets, range);
|
||||
}
|
||||
@ -3034,10 +3036,10 @@ bool Ia32CodeGenerator::TryFastCaseSwitchStatement(SwitchStatement *node) {
|
||||
ZoneList<CaseClause*>* cases = node->cases();
|
||||
int length = cases->length();
|
||||
|
||||
if (length < kFastSwitchMinCaseCount) {
|
||||
if (length < kFastSwitchMinCaseCount) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Test whether fast-case should be used.
|
||||
int default_index = -1;
|
||||
int min_index = Smi::kMaxValue;
|
||||
@ -3065,7 +3067,8 @@ bool Ia32CodeGenerator::TryFastCaseSwitchStatement(SwitchStatement *node) {
|
||||
if (smi > max_index) { max_index = smi; }
|
||||
}
|
||||
}
|
||||
// all labels are Smi.
|
||||
|
||||
// After this all labels are smis.
|
||||
int range = max_index - min_index + 1; // |min..max| inclusive
|
||||
if (range / kFastSwitchMaxOverheadFactor > length) {
|
||||
return false; // range of labels is too sparse
|
||||
|
Loading…
Reference in New Issue
Block a user