Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(491)

Unified Diff: src/ia32/codegen-ia32.cc

Issue 113458: First round of size reduction for JumpTargets. Reduce their size by... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/ia32/codegen-ia32.cc
===================================================================
--- src/ia32/codegen-ia32.cc (revision 1967)
+++ src/ia32/codegen-ia32.cc (working copy)
@@ -140,7 +140,7 @@
frame_->AllocateStackSlots(scope_->num_stack_slots());
// Initialize the function return target after the locals are set
// up, because it needs the expected frame height from the frame.
- function_return_.Initialize(this, JumpTarget::BIDIRECTIONAL);
+ function_return_.set_direction(JumpTarget::BIDIRECTIONAL);
function_return_is_shadowed_ = false;
// Allocate the arguments object and copy the parameters into it.
@@ -467,14 +467,14 @@
int original_height = frame_->height();
#endif
ASSERT(!in_spilled_code());
- JumpTarget true_target(this);
- JumpTarget false_target(this);
+ JumpTarget true_target;
+ JumpTarget false_target;
ControlDestination dest(&true_target, &false_target, true);
LoadCondition(x, typeof_state, &dest, false);
if (dest.false_was_fall_through()) {
// The false target was just bound.
- JumpTarget loaded(this);
+ JumpTarget loaded;
frame_->Push(Factory::false_value());
// There may be dangling jumps to the true target.
if (true_target.is_linked()) {
@@ -487,7 +487,7 @@
} else if (dest.is_used()) {
// There is true, and possibly false, control flow (with true as
// the fall through).
- JumpTarget loaded(this);
+ JumpTarget loaded;
frame_->Push(Factory::true_value());
if (false_target.is_linked()) {
loaded.Jump();
@@ -503,7 +503,7 @@
// short-circuited boolean operators).
ASSERT(has_valid_frame());
if (true_target.is_linked() || false_target.is_linked()) {
- JumpTarget loaded(this);
+ JumpTarget loaded;
loaded.Jump(); // Don't lose the current TOS.
if (true_target.is_linked()) {
true_target.Bind();
@@ -1540,7 +1540,7 @@
// where both sides are Smis.
left_side.ToRegister();
ASSERT(left_side.is_valid());
- JumpTarget is_smi(this);
+ JumpTarget is_smi;
__ test(left_side.reg(), Immediate(kSmiTagMask));
is_smi.Branch(zero, &left_side, &right_side, taken);
@@ -1611,7 +1611,7 @@
(right_side.is_constant() && !right_side.handle()->IsSmi());
left_side.ToRegister();
right_side.ToRegister();
- JumpTarget is_smi(this);
+ JumpTarget is_smi;
if (!known_non_smi) {
// Check for the smi case.
Result temp = allocator_->Allocate();
@@ -1756,7 +1756,7 @@
ASSERT(!in_spilled_code());
Comment cmnt(masm_, "[ Block");
CodeForStatementPosition(node);
- node->break_target()->Initialize(this);
+ node->break_target()->set_direction(JumpTarget::FORWARD_ONLY);
VisitStatements(node->statements());
if (node->break_target()->is_linked()) {
node->break_target()->Bind();
@@ -1870,10 +1870,10 @@
bool has_else_stm = node->HasElseStatement();
CodeForStatementPosition(node);
- JumpTarget exit(this);
+ JumpTarget exit;
if (has_then_stm && has_else_stm) {
- JumpTarget then(this);
- JumpTarget else_(this);
+ JumpTarget then;
+ JumpTarget else_;
ControlDestination dest(&then, &else_, true);
LoadCondition(node->condition(), NOT_INSIDE_TYPEOF, &dest, true);
@@ -1900,7 +1900,7 @@
} else if (has_then_stm) {
ASSERT(!has_else_stm);
- JumpTarget then(this);
+ JumpTarget then;
ControlDestination dest(&then, &exit, true);
LoadCondition(node->condition(), NOT_INSIDE_TYPEOF, &dest, true);
@@ -1920,7 +1920,7 @@
} else if (has_else_stm) {
ASSERT(!has_then_stm);
- JumpTarget else_(this);
+ JumpTarget else_;
ControlDestination dest(&exit, &else_, false);
LoadCondition(node->condition(), NOT_INSIDE_TYPEOF, &dest, true);
@@ -2087,8 +2087,8 @@
// placeholders, and fill in the addresses after the labels have been
// bound.
- JumpTarget setup_default(this);
- JumpTarget is_smi(this);
+ JumpTarget setup_default;
+ JumpTarget is_smi;
// A non-null default label pointer indicates a default case among
// the case labels. Otherwise we use the break target as a
@@ -2133,7 +2133,7 @@
// frame of the correct height can be merged to). Keep a copy to
// restore at the start of every label. Create a jump target and
// bind it to set its entry frame properly.
- JumpTarget entry_target(this, JumpTarget::BIDIRECTIONAL);
+ JumpTarget entry_target(JumpTarget::BIDIRECTIONAL);
entry_target.Bind(&smi_value);
VirtualFrame* start_frame = new VirtualFrame(frame_);
@@ -2190,7 +2190,7 @@
ASSERT(!in_spilled_code());
Comment cmnt(masm_, "[ SwitchStatement");
CodeForStatementPosition(node);
- node->break_target()->Initialize(this);
+ node->break_target()->set_direction(JumpTarget::FORWARD_ONLY);
// Compile the switch value.
Load(node->tag());
@@ -2203,7 +2203,7 @@
int length = cases->length();
CaseClause* default_clause = NULL;
- JumpTarget next_test(this);
+ JumpTarget next_test;
// Compile the case label expressions and comparisons. Exit early
// if a comparison is unconditionally true. The target next_test is
// bound before the loop in order to indicate control flow to the
@@ -2211,7 +2211,6 @@
next_test.Bind();
for (int i = 0; i < length && !next_test.is_unused(); i++) {
CaseClause* clause = cases->at(i);
- clause->body_target()->Initialize(this);
// The default is not a test, but remember it for later.
if (clause->is_default()) {
default_clause = clause;
@@ -2282,7 +2281,7 @@
if (clause->is_default()) {
clause->body_target()->Bind();
} else {
- JumpTarget body(this);
+ JumpTarget body;
body.Jump();
clause->body_target()->Bind();
frame_->Drop();
@@ -2320,7 +2319,7 @@
ASSERT(!in_spilled_code());
Comment cmnt(masm_, "[ LoopStatement");
CodeForStatementPosition(node);
- node->break_target()->Initialize(this);
+ node->break_target()->set_direction(JumpTarget::FORWARD_ONLY);
// Simple condition analysis. ALWAYS_TRUE and ALWAYS_FALSE represent a
// known result for the test expression, with no side effects.
@@ -2341,21 +2340,21 @@
switch (node->type()) {
case LoopStatement::DO_LOOP: {
- JumpTarget body(this, JumpTarget::BIDIRECTIONAL);
+ JumpTarget body(JumpTarget::BIDIRECTIONAL);
IncrementLoopNesting();
// Label the top of the loop for the backward jump if necessary.
if (info == ALWAYS_TRUE) {
// Use the continue target.
- node->continue_target()->Initialize(this, JumpTarget::BIDIRECTIONAL);
+ node->continue_target()->set_direction(JumpTarget::BIDIRECTIONAL);
node->continue_target()->Bind();
} else if (info == ALWAYS_FALSE) {
// No need to label it.
- node->continue_target()->Initialize(this);
+ node->continue_target()->set_direction(JumpTarget::FORWARD_ONLY);
} else {
// Continue is the test, so use the backward body target.
ASSERT(info == DONT_KNOW);
- node->continue_target()->Initialize(this);
+ node->continue_target()->set_direction(JumpTarget::FORWARD_ONLY);
body.Bind();
}
@@ -2414,27 +2413,25 @@
JumpTarget body;
if (test_at_bottom) {
- body.Initialize(this, JumpTarget::BIDIRECTIONAL);
- } else {
- body.Initialize(this);
+ body.set_direction(JumpTarget::BIDIRECTIONAL);
}
// Based on the condition analysis, compile the test as necessary.
if (info == ALWAYS_TRUE) {
// We will not compile the test expression. Label the top of
// the loop with the continue target.
- node->continue_target()->Initialize(this, JumpTarget::BIDIRECTIONAL);
+ node->continue_target()->set_direction(JumpTarget::BIDIRECTIONAL);
node->continue_target()->Bind();
} else {
ASSERT(info == DONT_KNOW); // ALWAYS_FALSE cannot reach here.
if (test_at_bottom) {
// Continue is the test at the bottom, no need to label the
// test at the top. The body is a backward target.
- node->continue_target()->Initialize(this);
+ node->continue_target()->set_direction(JumpTarget::FORWARD_ONLY);
} else {
// Label the test at the top as the continue target. The
// body is a forward-only target.
- node->continue_target()->Initialize(this, JumpTarget::BIDIRECTIONAL);
+ node->continue_target()->set_direction(JumpTarget::BIDIRECTIONAL);
node->continue_target()->Bind();
}
// Compile the test with the body as the true target and
@@ -2517,15 +2514,13 @@
// Target for backward edge if no test at the bottom, otherwise
// unused.
- JumpTarget loop(this, JumpTarget::BIDIRECTIONAL);
+ JumpTarget loop(JumpTarget::BIDIRECTIONAL);
// Target for backward edge if there is a test at the bottom,
// otherwise used as target for test at the top.
JumpTarget body;
if (test_at_bottom) {
- body.Initialize(this, JumpTarget::BIDIRECTIONAL);
- } else {
- body.Initialize(this);
+ body.set_direction(JumpTarget::BIDIRECTIONAL);
}
// Based on the condition analysis, compile the test as necessary.
@@ -2534,11 +2529,11 @@
// the loop.
if (node->next() == NULL) {
// Use the continue target if there is no update expression.
- node->continue_target()->Initialize(this, JumpTarget::BIDIRECTIONAL);
+ node->continue_target()->set_direction(JumpTarget::BIDIRECTIONAL);
node->continue_target()->Bind();
} else {
// Otherwise use the backward loop target.
- node->continue_target()->Initialize(this);
+ node->continue_target()->set_direction(JumpTarget::FORWARD_ONLY);
loop.Bind();
}
} else {
@@ -2546,16 +2541,16 @@
if (test_at_bottom) {
// Continue is either the update expression or the test at
// the bottom, no need to label the test at the top.
- node->continue_target()->Initialize(this);
+ node->continue_target()->set_direction(JumpTarget::FORWARD_ONLY);
} else if (node->next() == NULL) {
// We are not recompiling the test at the bottom and there
// is no update expression.
- node->continue_target()->Initialize(this, JumpTarget::BIDIRECTIONAL);
+ node->continue_target()->set_direction(JumpTarget::BIDIRECTIONAL);
node->continue_target()->Bind();
} else {
// We are not recompiling the test at the bottom and there
// is an update expression.
- node->continue_target()->Initialize(this);
+ node->continue_target()->set_direction(JumpTarget::FORWARD_ONLY);
loop.Bind();
}
@@ -2659,12 +2654,12 @@
Comment cmnt(masm_, "[ ForInStatement");
CodeForStatementPosition(node);
- JumpTarget primitive(this);
- JumpTarget jsobject(this);
- JumpTarget fixed_array(this);
- JumpTarget entry(this, JumpTarget::BIDIRECTIONAL);
- JumpTarget end_del_check(this);
- JumpTarget exit(this);
+ JumpTarget primitive;
+ JumpTarget jsobject;
+ JumpTarget fixed_array;
+ JumpTarget entry(JumpTarget::BIDIRECTIONAL);
+ JumpTarget end_del_check;
+ JumpTarget exit;
// Get the object to enumerate over (converted to JSObject).
LoadAndSpill(node->enumerable());
@@ -2749,8 +2744,8 @@
entry.Bind();
// Grab the current frame's height for the break and continue
// targets only after all the state is pushed on the frame.
- node->break_target()->Initialize(this);
- node->continue_target()->Initialize(this);
+ node->break_target()->set_direction(JumpTarget::FORWARD_ONLY);
+ node->continue_target()->set_direction(JumpTarget::FORWARD_ONLY);
__ mov(eax, frame_->ElementAt(0)); // load the current count
__ cmp(eax, frame_->ElementAt(1)); // compare to the array length
@@ -2849,8 +2844,8 @@
Comment cmnt(masm_, "[ TryCatch");
CodeForStatementPosition(node);
- JumpTarget try_block(this);
- JumpTarget exit(this);
+ JumpTarget try_block;
+ JumpTarget exit;
try_block.Call();
// --- Catch block ---
@@ -2993,8 +2988,8 @@
// break/continue from within the try block.
enum { FALLING, THROWING, JUMPING };
- JumpTarget try_block(this);
- JumpTarget finally_block(this);
+ JumpTarget try_block;
+ JumpTarget finally_block;
try_block.Call();
@@ -3146,7 +3141,7 @@
} else {
// Branch around the preparation for return which may emit
// code.
- JumpTarget skip(this);
+ JumpTarget skip;
skip.Branch(not_equal);
frame_->PrepareForReturn();
original->Jump(&return_value);
@@ -3160,7 +3155,7 @@
if (has_valid_frame()) {
// Check if we need to rethrow the exception.
- JumpTarget exit(this);
+ JumpTarget exit;
__ cmp(Operand(ecx), Immediate(Smi::FromInt(THROWING)));
exit.Branch(not_equal);
@@ -3220,9 +3215,9 @@
void CodeGenerator::VisitConditional(Conditional* node) {
Comment cmnt(masm_, "[ Conditional");
- JumpTarget then(this);
- JumpTarget else_(this);
- JumpTarget exit(this);
+ JumpTarget then;
+ JumpTarget else_;
+ JumpTarget exit;
ControlDestination dest(&then, &else_, true);
LoadCondition(node->condition(), NOT_INSIDE_TYPEOF, &dest, true);
@@ -3254,8 +3249,8 @@
if (slot->type() == Slot::LOOKUP) {
ASSERT(slot->var()->is_dynamic());
- JumpTarget slow(this);
- JumpTarget done(this);
+ JumpTarget slow;
+ JumpTarget done;
Result value;
// Generate fast-case code for variables that might be shadowed by
@@ -3321,7 +3316,7 @@
// potentially unsafe direct-frame access of SlotOperand.
VirtualFrame::SpilledScope spilled_scope(this);
Comment cmnt(masm_, "[ Load const");
- JumpTarget exit(this);
+ JumpTarget exit;
__ mov(ecx, SlotOperand(slot, ecx));
__ cmp(ecx, Factory::the_hole_value());
exit.Branch(not_equal);
@@ -3459,7 +3454,7 @@
} else {
ASSERT(!slot->var()->is_dynamic());
- JumpTarget exit(this);
+ JumpTarget exit;
if (init_state == CONST_INIT) {
ASSERT(slot->var()->mode() == Variable::CONST);
// Only the first const initialization must be executed (the slot
@@ -4284,13 +4279,13 @@
void CodeGenerator::GenerateFastCharCodeAt(ZoneList<Expression*>* args) {
ASSERT(args->length() == 2);
- JumpTarget slow_case(this);
- JumpTarget end(this);
- JumpTarget not_a_flat_string(this);
- JumpTarget a_cons_string(this);
- JumpTarget try_again_with_new_string(this, JumpTarget::BIDIRECTIONAL);
- JumpTarget ascii_string(this);
- JumpTarget got_char_code(this);
+ JumpTarget slow_case;
+ JumpTarget end;
+ JumpTarget not_a_flat_string;
+ JumpTarget a_cons_string;
+ JumpTarget try_again_with_new_string(JumpTarget::BIDIRECTIONAL);
+ JumpTarget ascii_string;
+ JumpTarget got_char_code;
Load(args->at(0));
Load(args->at(1));
@@ -4448,7 +4443,7 @@
void CodeGenerator::GenerateValueOf(ZoneList<Expression*>* args) {
ASSERT(args->length() == 1);
- JumpTarget leave(this);
+ JumpTarget leave;
Load(args->at(0)); // Load the object.
frame_->Dup();
Result object = frame_->Pop();
@@ -4472,7 +4467,7 @@
void CodeGenerator::GenerateSetValueOf(ZoneList<Expression*>* args) {
ASSERT(args->length() == 2);
- JumpTarget leave(this);
+ JumpTarget leave;
Load(args->at(0)); // Load the object.
Load(args->at(1)); // Load the value.
Result value = frame_->Pop();
@@ -4701,8 +4696,8 @@
case Token::BIT_NOT: {
// Smi check.
- JumpTarget smi_label(this);
- JumpTarget continue_label(this);
+ JumpTarget smi_label;
+ JumpTarget continue_label;
Result operand = frame_->Pop();
operand.ToRegister();
__ test(operand.reg(), Immediate(kSmiTagMask));
@@ -4725,7 +4720,7 @@
case Token::ADD: {
// Smi check.
- JumpTarget continue_label(this);
+ JumpTarget continue_label;
Result operand = frame_->Pop();
operand.ToRegister();
__ test(operand.reg(), Immediate(kSmiTagMask));
@@ -4920,7 +4915,7 @@
// is necessary because we assume that if we get control flow on the
// last path out of an expression we got it on all paths.
if (op == Token::AND) {
- JumpTarget is_true(this);
+ JumpTarget is_true;
ControlDestination dest(&is_true, destination()->false_target(), true);
LoadCondition(node->left(), NOT_INSIDE_TYPEOF, &dest, false);
@@ -4958,8 +4953,8 @@
// We have a materialized value on the frame, so we exit with
// one on all paths. There are possibly also jumps to is_true
// from nested subexpressions.
- JumpTarget pop_and_continue(this);
- JumpTarget exit(this);
+ JumpTarget pop_and_continue;
+ JumpTarget exit;
// Avoid popping the result if it converts to 'false' using the
// standard ToBoolean() conversion as described in ECMA-262,
@@ -4983,7 +4978,7 @@
}
} else if (op == Token::OR) {
- JumpTarget is_false(this);
+ JumpTarget is_false;
ControlDestination dest(destination()->true_target(), &is_false, false);
LoadCondition(node->left(), NOT_INSIDE_TYPEOF, &dest, false);
@@ -5020,8 +5015,8 @@
// We have a materialized value on the frame, so we exit with
// one on all paths. There are possibly also jumps to is_false
// from nested subexpressions.
- JumpTarget pop_and_continue(this);
- JumpTarget exit(this);
+ JumpTarget pop_and_continue;
+ JumpTarget exit;
// Avoid popping the result if it converts to 'true' using the
// standard ToBoolean() conversion as described in ECMA-262,
@@ -5975,7 +5970,7 @@
// the left and right arguments, and jump to slow case.
// The low bit of the left argument may be lost, but only
// in a case where it is dropped anyway.
- JumpTarget result_ok(generator());
+ JumpTarget result_ok;
__ test(left->reg(), Immediate(0xc0000000));
result_ok.Branch(zero, left, taken);
__ shl(left->reg());
@@ -5989,7 +5984,7 @@
case Token::SHL: {
__ shl(left->reg());
// Check that the *signed* result fits in a smi.
- JumpTarget result_ok(generator());
+ JumpTarget result_ok;
__ cmp(left->reg(), 0xc0000000);
result_ok.Branch(positive, left, taken);
« no previous file with comments | « src/codegen.cc ('k') | src/ia32/jump-target-ia32.cc » ('j') | src/jump-target.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698