Commit ef85ba46 authored by ager@chromium.org's avatar ager@chromium.org

First round of size reduction for JumpTargets. Reduce their size by

two words: there is no reason to keep a pointer to the current code
generator and macro assembler in the JumpTarget.
Review URL: http://codereview.chromium.org/113458

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1987 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 13a96b3a
This diff is collapsed.
This diff is collapsed.
...@@ -47,8 +47,7 @@ CodeGenerator* CodeGeneratorScope::top_ = NULL; ...@@ -47,8 +47,7 @@ CodeGenerator* CodeGeneratorScope::top_ = NULL;
DeferredCode::DeferredCode(CodeGenerator* generator) DeferredCode::DeferredCode(CodeGenerator* generator)
: generator_(generator), : generator_(generator),
masm_(generator->masm()), masm_(generator->masm()),
enter_(generator), exit_(JumpTarget::BIDIRECTIONAL),
exit_(generator, JumpTarget::BIDIRECTIONAL),
statement_position_(masm_->current_statement_position()), statement_position_(masm_->current_statement_position()),
position_(masm_->current_position()) { position_(masm_->current_position()) {
generator->AddDeferred(this); generator->AddDeferred(this);
......
This diff is collapsed.
This diff is collapsed.
...@@ -631,7 +631,7 @@ void MacroAssembler::NegativeZeroTest(CodeGenerator* cgen, ...@@ -631,7 +631,7 @@ void MacroAssembler::NegativeZeroTest(CodeGenerator* cgen,
Register result, Register result,
Register op, Register op,
JumpTarget* then_target) { JumpTarget* then_target) {
JumpTarget ok(cgen); JumpTarget ok;
test(result, Operand(result)); test(result, Operand(result));
ok.Branch(not_zero, taken); ok.Branch(not_zero, taken);
test(op, Operand(op)); test(op, Operand(op));
......
...@@ -30,6 +30,10 @@ ...@@ -30,6 +30,10 @@
namespace v8 { namespace internal { namespace v8 { namespace internal {
CodeGenerator* JumpTarget::cgen() {
return CodeGeneratorScope::Current();
}
void JumpTarget::InitializeEntryElement(int index, FrameElement* target) { void JumpTarget::InitializeEntryElement(int index, FrameElement* target) {
entry_frame_->elements_[index].clear_copied(); entry_frame_->elements_[index].clear_copied();
if (target->is_register()) { if (target->is_register()) {
......
This diff is collapsed.
...@@ -56,31 +56,34 @@ class JumpTarget : public ZoneObject { // Shadows are dynamically allocated. ...@@ -56,31 +56,34 @@ class JumpTarget : public ZoneObject { // Shadows are dynamically allocated.
// Forward-only jump targets can only be reached by forward CFG edges. // Forward-only jump targets can only be reached by forward CFG edges.
enum Directionality { FORWARD_ONLY, BIDIRECTIONAL }; enum Directionality { FORWARD_ONLY, BIDIRECTIONAL };
// Construct a jump target with a given code generator used to generate // Construct a jump target used to generate code and to provide
// code and to provide access to a current frame. // access to a current frame.
explicit JumpTarget(CodeGenerator* cgen, explicit JumpTarget(Directionality direction)
Directionality direction = FORWARD_ONLY); : direction_(direction),
reaching_frames_(0),
merge_labels_(0),
entry_frame_(NULL) {
}
// Construct a jump target without a code generator. A code // Construct a jump target.
// generator must be supplied before using the jump target as a JumpTarget()
// label. This is useful, eg, when break targets are embedded in : direction_(FORWARD_ONLY),
// AST nodes. reaching_frames_(0),
JumpTarget(); merge_labels_(0),
entry_frame_(NULL) {
}
virtual ~JumpTarget() {} virtual ~JumpTarget() {}
// Supply a code generator and directionality to an already // Set the direction of the jump target.
// constructed jump target. This function expects to be given a virtual void set_direction(Directionality direction) {
// non-null code generator, and to be called only when the code direction_ = direction;
// generator is not yet set. }
virtual void Initialize(CodeGenerator* cgen,
Directionality direction = FORWARD_ONLY);
// Treat the jump target as a fresh one. The state is reset. // Treat the jump target as a fresh one. The state is reset.
void Unuse(); void Unuse();
// Accessors. inline CodeGenerator* cgen();
CodeGenerator* code_generator() const { return cgen_; }
Label* entry_label() { return &entry_label_; } Label* entry_label() { return &entry_label_; }
...@@ -163,12 +166,6 @@ class JumpTarget : public ZoneObject { // Shadows are dynamically allocated. ...@@ -163,12 +166,6 @@ class JumpTarget : public ZoneObject { // Shadows are dynamically allocated.
} }
protected: protected:
// The code generator gives access to its current frame.
CodeGenerator* cgen_;
// Used to emit code.
MacroAssembler* masm_;
// Directionality flag set at initialization time. // Directionality flag set at initialization time.
Directionality direction_; Directionality direction_;
...@@ -224,20 +221,13 @@ class JumpTarget : public ZoneObject { // Shadows are dynamically allocated. ...@@ -224,20 +221,13 @@ class JumpTarget : public ZoneObject { // Shadows are dynamically allocated.
class BreakTarget : public JumpTarget { class BreakTarget : public JumpTarget {
public: public:
// Construct a break target without a code generator. A code // Construct a break target.
// generator must be supplied before using the break target as a
// label. This is useful, eg, when break targets are embedded in AST
// nodes.
BreakTarget() {} BreakTarget() {}
virtual ~BreakTarget() {} virtual ~BreakTarget() {}
// Supply a code generator, expected expression stack height, and // Set the direction of the break target.
// directionality to an already constructed break target. This virtual void set_direction(Directionality direction);
// function expects to be given a non-null code generator, and to be
// called only when the code generator is not yet set.
virtual void Initialize(CodeGenerator* cgen,
Directionality direction = FORWARD_ONLY);
// Copy the state of this break target to the destination. The // Copy the state of this break target to the destination. The
// lists of forward-reaching frames and merge-point labels are // lists of forward-reaching frames and merge-point labels are
......
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