Showing with 177 additions and 33 deletions.
  1. +2 −1 src/heap-inl.h
  2. +17 −0 src/hir-instructions-inl.h
  3. +72 −17 src/hir-instructions.cc
  4. +28 −3 src/hir-instructions.h
  5. +42 −0 src/hir.cc
  6. +2 −0 src/hir.h
  7. +4 −2 src/ia32/macroassembler-ia32.cc
  8. +4 −0 src/lir.cc
  9. +4 −2 src/x64/macroassembler-x64.cc
  10. +2 −8 test/test-hir.cc
@@ -139,7 +139,8 @@ inline void HArray::SetLength(char* obj, int64_t length) {


inline bool HArray::IsDense(char* obj) {
return Length(obj, false) <= kDenseLengthMax;
int size = HValue::As<HMap>(Map(obj))->size();
return size <= kDenseLengthMax;
}


@@ -94,6 +94,23 @@ inline bool HIRInstruction::IsBoolean() {
}


inline bool HIRInstruction::IsPinned() {
return pinned_;
}


inline HIRInstruction* HIRInstruction::Unpin() {
pinned_ = false;
return this;
}


inline HIRInstruction* HIRInstruction::Pin() {
pinned_ = true;
return this;
}


inline HIRBlock* HIRInstruction::block() {
return block_;
}
@@ -9,6 +9,7 @@ namespace internal {
HIRInstruction::HIRInstruction(Type type) :
id(-1),
gcm_visited(0),
is_live(0),
type_(type),
slot_(NULL),
ast_(NULL),
@@ -22,6 +23,7 @@ HIRInstruction::HIRInstruction(Type type) :
HIRInstruction::HIRInstruction(Type type, ScopeSlot* slot) :
id(-1),
gcm_visited(0),
is_live(0),
type_(type),
slot_(slot),
ast_(NULL),
@@ -38,6 +40,11 @@ void HIRInstruction::Init(HIRGen* g, HIRBlock* block) {
}


inline bool HIRInstruction::HasSideEffects() {
return false;
}


inline void HIRInstruction::CalculateRepresentation() {
representation_ = kUnknownRepresentation;
}
@@ -115,23 +122,6 @@ void HIRInstruction::Print(PrintBuffer* p) {
}


bool HIRInstruction::IsPinned() {
return pinned_;
}


HIRInstruction* HIRInstruction::Unpin() {
pinned_ = false;
return this;
}


HIRInstruction* HIRInstruction::Pin() {
pinned_ = true;
return this;
}


HIRPhi::HIRPhi(ScopeSlot* slot) : HIRInstruction(kPhi, slot),
input_count_(0) {
inputs_[0] = NULL;
@@ -220,6 +210,11 @@ HIREntry::HIREntry(int context_slots_) : HIRInstruction(kEntry),
}


bool HIREntry::HasSideEffects() {
return true;
}


void HIREntry::Print(PrintBuffer* p) {
p->Print("i%d = Entry[%d]\n", id, context_slots_);
}
@@ -229,22 +224,47 @@ HIRReturn::HIRReturn() : HIRInstruction(kReturn) {
}


bool HIRReturn::HasSideEffects() {
return true;
}


HIRIf::HIRIf() : HIRInstruction(kIf) {
}


bool HIRIf::HasSideEffects() {
return true;
}


HIRGoto::HIRGoto() : HIRInstruction(kGoto) {
}


bool HIRGoto::HasSideEffects() {
return true;
}


HIRCollectGarbage::HIRCollectGarbage() : HIRInstruction(kCollectGarbage) {
}


bool HIRCollectGarbage::HasSideEffects() {
return true;
}


HIRGetStackTrace::HIRGetStackTrace() : HIRInstruction(kGetStackTrace) {
}


bool HIRGetStackTrace::HasSideEffects() {
return true;
}


HIRBinOp::HIRBinOp(BinOp::BinOpType type) : HIRInstruction(kBinOp),
binop_type_(type) {
}
@@ -291,6 +311,11 @@ HIRStoreContext::HIRStoreContext(ScopeSlot* slot) :
}


bool HIRStoreContext::HasSideEffects() {
return true;
}


void HIRStoreContext::CalculateRepresentation() {
// Basically store property returns it's first argument
assert(args()->length() == 1);
@@ -306,6 +331,11 @@ HIRStoreProperty::HIRStoreProperty() : HIRInstruction(kStoreProperty) {
}


bool HIRStoreProperty::HasSideEffects() {
return true;
}


void HIRStoreProperty::CalculateRepresentation() {
// Basically store property returns it's first argument
assert(args()->length() == 3);
@@ -343,6 +373,11 @@ HIRLoadVarArg::HIRLoadVarArg() : HIRInstruction(kLoadVarArg) {
}


bool HIRLoadVarArg::HasSideEffects() {
return true;
}


void HIRLoadVarArg::CalculateRepresentation() {
representation_ = kArrayRepresentation;
}
@@ -352,18 +387,38 @@ HIRStoreArg::HIRStoreArg() : HIRInstruction(kStoreArg) {
}


bool HIRStoreArg::HasSideEffects() {
return true;
}


HIRStoreVarArg::HIRStoreVarArg() : HIRInstruction(kStoreVarArg) {
}


bool HIRStoreVarArg::HasSideEffects() {
return true;
}


HIRAlignStack::HIRAlignStack() : HIRInstruction(kAlignStack) {
}


bool HIRAlignStack::HasSideEffects() {
return true;
}


HIRCall::HIRCall() : HIRInstruction(kCall) {
}


bool HIRCall::HasSideEffects() {
return true;
}


HIRKeysof::HIRKeysof() : HIRInstruction(kKeysof) {
}

@@ -86,11 +86,10 @@ class HIRInstruction : public ZoneObject {

int id;
int gcm_visited;
int is_live;

virtual void ReplaceArg(HIRInstruction* o, HIRInstruction* n);
bool IsPinned();
HIRInstruction* Unpin();
HIRInstruction* Pin();
virtual bool HasSideEffects();
virtual void CalculateRepresentation();
void Remove();
void RemoveUse(HIRInstruction* i);
@@ -110,6 +109,10 @@ class HIRInstruction : public ZoneObject {
inline bool IsString();
inline bool IsBoolean();

inline bool IsPinned();
inline HIRInstruction* Unpin();
inline HIRInstruction* Pin();

inline HIRBlock* block();
inline void block(HIRBlock* block);
inline ScopeSlot* slot();
@@ -214,6 +217,7 @@ class HIREntry : public HIRInstruction {
HIREntry(int context_slots);

void Print(PrintBuffer* p);
bool HasSideEffects();
inline int context_slots();

HIR_DEFAULT_METHODS(Entry)
@@ -226,6 +230,8 @@ class HIRReturn : public HIRInstruction {
public:
HIRReturn();

bool HasSideEffects();

HIR_DEFAULT_METHODS(Return)

private:
@@ -235,6 +241,8 @@ class HIRIf : public HIRInstruction {
public:
HIRIf();

bool HasSideEffects();

HIR_DEFAULT_METHODS(If)

private:
@@ -244,6 +252,8 @@ class HIRGoto : public HIRInstruction {
public:
HIRGoto();

bool HasSideEffects();

HIR_DEFAULT_METHODS(Goto)

private:
@@ -253,6 +263,8 @@ class HIRCollectGarbage : public HIRInstruction {
public:
HIRCollectGarbage();

bool HasSideEffects();

HIR_DEFAULT_METHODS(CollectGarbage)

private:
@@ -262,6 +274,8 @@ class HIRGetStackTrace : public HIRInstruction {
public:
HIRGetStackTrace();

bool HasSideEffects();

HIR_DEFAULT_METHODS(GetStackTrace)

private:
@@ -297,6 +311,7 @@ class HIRStoreContext : public HIRInstruction {
HIRStoreContext(ScopeSlot* slot);

void CalculateRepresentation();
bool HasSideEffects();
inline ScopeSlot* context_slot();

HIR_DEFAULT_METHODS(StoreContext)
@@ -318,6 +333,7 @@ class HIRStoreProperty : public HIRInstruction {
public:
HIRStoreProperty();

bool HasSideEffects();
void CalculateRepresentation();

HIR_DEFAULT_METHODS(StoreProperty)
@@ -369,6 +385,7 @@ class HIRLoadVarArg : public HIRInstruction {
public:
HIRLoadVarArg();

bool HasSideEffects();
void CalculateRepresentation();

HIR_DEFAULT_METHODS(LoadVarArg)
@@ -380,6 +397,8 @@ class HIRStoreArg : public HIRInstruction {
public:
HIRStoreArg();

bool HasSideEffects();

HIR_DEFAULT_METHODS(StoreArg)

private:
@@ -389,6 +408,8 @@ class HIRStoreVarArg : public HIRInstruction {
public:
HIRStoreVarArg();

bool HasSideEffects();

HIR_DEFAULT_METHODS(StoreVarArg)

private:
@@ -398,6 +419,8 @@ class HIRAlignStack : public HIRInstruction {
public:
HIRAlignStack();

bool HasSideEffects();

HIR_DEFAULT_METHODS(AlignStack)

private:
@@ -407,6 +430,8 @@ class HIRCall : public HIRInstruction {
public:
HIRCall();

bool HasSideEffects();

HIR_DEFAULT_METHODS(Call)

private: