Index: src/hydrogen.h |
diff --git a/src/hydrogen.h b/src/hydrogen.h |
index 97c9a6a21b1ffe9a0fefc8428c9ea1954515294f..0a2ca08aae858cfe6065dbfe58f1081869a3e79b 100644 |
--- a/src/hydrogen.h |
+++ b/src/hydrogen.h |
@@ -46,6 +46,7 @@ class FunctionState; |
class HEnvironment; |
class HGraph; |
class HLoopInformation; |
+class HOsrBuilder; |
class HTracer; |
class LAllocator; |
class LChunk; |
@@ -230,6 +231,19 @@ class HPredecessorIterator BASE_EMBEDDED { |
}; |
+class HInstructionIterator BASE_EMBEDDED { |
+ public: |
+ explicit HInstructionIterator(HBasicBlock* block) : instr_(block->first()) { } |
+ |
+ bool Done() { return instr_ == NULL; } |
+ HInstruction* Current() { return instr_; } |
+ void Advance() { instr_ = instr_->next(); } |
+ |
+ private: |
+ HInstruction* instr_; |
+}; |
+ |
+ |
class HLoopInformation: public ZoneObject { |
public: |
HLoopInformation(HBasicBlock* loop_header, Zone* zone) |
@@ -277,23 +291,17 @@ class HGraph: public ZoneObject { |
HEnvironment* start_environment() const { return start_environment_; } |
void FinalizeUniqueValueIds(); |
- void InitializeInferredTypes(); |
void InsertTypeConversions(); |
void MergeRemovableSimulates(); |
- void InsertRepresentationChanges(); |
void MarkDeoptimizeOnUndefined(); |
void ComputeMinusZeroChecks(); |
- void ComputeSafeUint32Operations(); |
bool ProcessArgumentsObject(); |
- void EliminateRedundantPhis(); |
void Canonicalize(); |
void OrderBlocks(); |
void AssignDominators(); |
void SetupInformativeDefinitions(); |
- void EliminateRedundantBoundsChecks(); |
void DehoistSimpleArrayIndexComputations(); |
void RestoreActualValues(); |
- void DeadCodeElimination(const char *phase_name); |
void PropagateDeoptimizingMark(); |
void AnalyzeAndPruneEnvironmentLiveness(); |
@@ -320,6 +328,8 @@ class HGraph: public ZoneObject { |
HConstant* GetConstantNull(); |
HConstant* GetInvalidContext(); |
+ bool IsStandardConstant(HConstant* constant); |
+ |
HBasicBlock* CreateBasicBlock(); |
HArgumentsObject* GetArgumentsObject() const { |
return arguments_object_.get(); |
@@ -346,24 +356,16 @@ class HGraph: public ZoneObject { |
void Verify(bool do_full_verify) const; |
#endif |
- bool has_osr_loop_entry() { |
- return osr_loop_entry_.is_set(); |
- } |
- |
- HBasicBlock* osr_loop_entry() { |
- return osr_loop_entry_.get(); |
+ bool has_osr() { |
+ return osr_ != NULL; |
} |
- void set_osr_loop_entry(HBasicBlock* entry) { |
- osr_loop_entry_.set(entry); |
+ void set_osr(HOsrBuilder* osr) { |
+ osr_ = osr; |
} |
- ZoneList<HUnknownOSRValue*>* osr_values() { |
- return osr_values_.get(); |
- } |
- |
- void set_osr_values(ZoneList<HUnknownOSRValue*>* values) { |
- osr_values_.set(values); |
+ HOsrBuilder* osr() { |
+ return osr_; |
} |
int update_type_change_checksum(int delta) { |
@@ -416,7 +418,18 @@ class HGraph: public ZoneObject { |
return depends_on_empty_array_proto_elements_; |
} |
+ bool has_uint32_instructions() { |
+ ASSERT(uint32_instructions_ == NULL || !uint32_instructions_->is_empty()); |
+ return uint32_instructions_ != NULL; |
+ } |
+ |
+ ZoneList<HInstruction*>* uint32_instructions() { |
+ ASSERT(uint32_instructions_ == NULL || !uint32_instructions_->is_empty()); |
+ return uint32_instructions_; |
+ } |
+ |
void RecordUint32Instruction(HInstruction* instr) { |
+ ASSERT(uint32_instructions_ == NULL || !uint32_instructions_->is_empty()); |
if (uint32_instructions_ == NULL) { |
uint32_instructions_ = new(zone()) ZoneList<HInstruction*>(4, zone()); |
} |
@@ -428,27 +441,19 @@ class HGraph: public ZoneObject { |
int32_t integer_value); |
template<class Phase> |
- void Run() { Phase phase(this); phase.Run(); } |
+ void Run() { |
+ Phase phase(this); |
+ phase.Run(); |
+ } |
- void MarkLive(HValue* ref, HValue* instr, ZoneList<HValue*>* worklist); |
- void MarkLiveInstructions(); |
- void RemoveDeadInstructions(); |
void MarkAsDeoptimizingRecursively(HBasicBlock* block); |
void NullifyUnreachableInstructions(); |
void InsertTypeConversions(HInstruction* instr); |
void PropagateMinusZeroChecks(HValue* value, BitVector* visited); |
void RecursivelyMarkPhiDeoptimizeOnUndefined(HPhi* phi); |
- void InsertRepresentationChangeForUse(HValue* value, |
- HValue* use_value, |
- int use_index, |
- Representation to); |
- void InsertRepresentationChangesForValue(HValue* value); |
- void InferTypes(ZoneList<HValue*>* worklist); |
- void InitializeInferredTypes(int from_inclusive, int to_inclusive); |
void CheckForBackEdge(HBasicBlock* block, HBasicBlock* successor); |
void SetupInformativeDefinitionsInBlock(HBasicBlock* block); |
void SetupInformativeDefinitionsRecursively(HBasicBlock* block); |
- void EliminateRedundantBoundsChecks(HBasicBlock* bb, BoundsCheckTable* table); |
Isolate* isolate_; |
int next_block_id_; |
@@ -469,8 +474,7 @@ class HGraph: public ZoneObject { |
SetOncePointer<HConstant> constant_invalid_context_; |
SetOncePointer<HArgumentsObject> arguments_object_; |
- SetOncePointer<HBasicBlock> osr_loop_entry_; |
- SetOncePointer<ZoneList<HUnknownOSRValue*> > osr_values_; |
+ HOsrBuilder* osr_; |
CompilationInfo* info_; |
Zone* zone_; |
@@ -703,25 +707,6 @@ class HEnvironment: public ZoneObject { |
}; |
-class HInferRepresentation BASE_EMBEDDED { |
- public: |
- explicit HInferRepresentation(HGraph* graph) |
- : graph_(graph), |
- worklist_(8, graph->zone()), |
- in_worklist_(graph->GetMaximumValueID(), graph->zone()) { } |
- |
- void Analyze(); |
- void AddToWorklist(HValue* current); |
- |
- private: |
- Zone* zone() const { return graph_->zone(); } |
- |
- HGraph* graph_; |
- ZoneList<HValue*> worklist_; |
- BitVector in_worklist_; |
-}; |
- |
- |
class HOptimizedGraphBuilder; |
enum ArgumentsAllowedFlag { |
@@ -994,9 +979,57 @@ class HGraphBuilder { |
// Adding instructions. |
HInstruction* AddInstruction(HInstruction* instr); |
+ |
+ template<class I> |
+ I* Add() { return static_cast<I*>(AddInstruction(new(zone()) I())); } |
+ |
+ template<class I, class P1> |
+ I* Add(P1 p1) { |
+ return static_cast<I*>(AddInstruction(new(zone()) I(p1))); |
+ } |
+ |
+ template<class I, class P1, class P2> |
+ I* Add(P1 p1, P2 p2) { |
+ return static_cast<I*>(AddInstruction(new(zone()) I(p1, p2))); |
+ } |
+ |
+ template<class I, class P1, class P2, class P3> |
+ I* Add(P1 p1, P2 p2, P3 p3) { |
+ return static_cast<I*>(AddInstruction(new(zone()) I(p1, p2, p3))); |
+ } |
+ |
+ template<class I, class P1, class P2, class P3, class P4> |
+ I* Add(P1 p1, P2 p2, P3 p3, P4 p4) { |
+ return static_cast<I*>(AddInstruction(new(zone()) I(p1, p2, p3, p4))); |
+ } |
+ |
+ template<class I, class P1, class P2, class P3, class P4, class P5> |
+ I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) { |
+ return static_cast<I*>(AddInstruction(new(zone()) I(p1, p2, p3, p4, p5))); |
+ } |
+ |
+ template<class I, class P1, class P2, class P3, class P4, class P5, class P6> |
+ I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) { |
+ return static_cast<I*>(AddInstruction( |
+ new(zone()) I(p1, p2, p3, p4, p5, p6))); |
+ } |
+ |
+ template<class I, class P1, class P2, class P3, |
+ class P4, class P5, class P6, class P7> |
+ I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) { |
+ return static_cast<I*>(AddInstruction( |
+ new(zone()) I(p1, p2, p3, p4, p5, p6, p7))); |
+ } |
+ |
+ template<class I, class P1, class P2, class P3, class P4, |
+ class P5, class P6, class P7, class P8> |
+ I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) { |
+ return static_cast<I*>(AddInstruction( |
+ new(zone()) I(p1, p2, p3, p4, p5, p6, p7, p8))); |
+ } |
+ |
void AddSimulate(BailoutId id, |
RemovableSimulate removable = FIXED_SIMULATE); |
- HBoundsCheck* AddBoundsCheck(HValue* index, HValue* length); |
HReturn* AddReturn(HValue* value); |
@@ -1080,6 +1113,17 @@ class HGraphBuilder { |
HLoadNamedField* AddLoadElements(HValue *object, HValue *typecheck = NULL); |
+ HLoadNamedField* AddLoadFixedArrayLength(HValue *object); |
+ |
+ HValue* AddLoadJSBuiltin(Builtins::JavaScript builtin, HContext* context); |
+ |
+ enum SoftDeoptimizeMode { |
+ MUST_EMIT_SOFT_DEOPT, |
+ CAN_OMIT_SOFT_DEOPT |
+ }; |
+ |
+ void AddSoftDeoptimize(SoftDeoptimizeMode mode = CAN_OMIT_SOFT_DEOPT); |
+ |
class IfBuilder { |
public: |
explicit IfBuilder(HGraphBuilder* builder, |
@@ -1091,13 +1135,6 @@ class HGraphBuilder { |
if (!finished_) End(); |
} |
- HInstruction* IfCompare( |
- HValue* left, |
- HValue* right, |
- Token::Value token); |
- |
- HInstruction* IfCompareMap(HValue* left, Handle<Map> map); |
- |
template<class Condition> |
HInstruction* If(HValue *p) { |
HControlInstruction* compare = new(zone()) Condition(p); |
@@ -1112,6 +1149,13 @@ class HGraphBuilder { |
return compare; |
} |
+ template<class Condition, class P2, class P3> |
+ HInstruction* If(HValue* p1, P2 p2, P3 p3) { |
+ HControlInstruction* compare = new(zone()) Condition(p1, p2, p3); |
+ AddCompare(compare); |
+ return compare; |
+ } |
+ |
template<class Condition, class P2> |
HInstruction* IfNot(HValue* p1, P2 p2) { |
HControlInstruction* compare = new(zone()) Condition(p1, p2); |
@@ -1123,17 +1167,15 @@ class HGraphBuilder { |
return compare; |
} |
- HInstruction* OrIfCompare( |
- HValue* p1, |
- HValue* p2, |
- Token::Value token) { |
- Or(); |
- return IfCompare(p1, p2, token); |
- } |
- |
- HInstruction* OrIfCompareMap(HValue* left, Handle<Map> map) { |
- Or(); |
- return IfCompareMap(left, map); |
+ template<class Condition, class P2, class P3> |
+ HInstruction* IfNot(HValue* p1, P2 p2, P3 p3) { |
+ HControlInstruction* compare = new(zone()) Condition(p1, p2, p3); |
+ AddCompare(compare); |
+ HBasicBlock* block0 = compare->SuccessorAt(0); |
+ HBasicBlock* block1 = compare->SuccessorAt(1); |
+ compare->SetSuccessorAt(0, block1); |
+ compare->SetSuccessorAt(1, block0); |
+ return compare; |
} |
template<class Condition> |
@@ -1148,17 +1190,10 @@ class HGraphBuilder { |
return If<Condition>(p1, p2); |
} |
- HInstruction* AndIfCompare( |
- HValue* p1, |
- HValue* p2, |
- Token::Value token) { |
- And(); |
- return IfCompare(p1, p2, token); |
- } |
- |
- HInstruction* AndIfCompareMap(HValue* left, Handle<Map> map) { |
- And(); |
- return IfCompareMap(left, map); |
+ template<class Condition, class P2, class P3> |
+ HInstruction* OrIf(HValue* p1, P2 p2, P3 p3) { |
+ Or(); |
+ return If<Condition>(p1, p2, p3); |
} |
template<class Condition> |
@@ -1173,6 +1208,12 @@ class HGraphBuilder { |
return If<Condition>(p1, p2); |
} |
+ template<class Condition, class P2, class P3> |
+ HInstruction* AndIf(HValue* p1, P2 p2, P3 p3) { |
+ And(); |
+ return If<Condition>(p1, p2, p3); |
+ } |
+ |
void Or(); |
void And(); |
@@ -1273,7 +1314,8 @@ class HGraphBuilder { |
JSArrayBuilder(HGraphBuilder* builder, |
ElementsKind kind, |
HValue* allocation_site_payload, |
- bool disable_allocation_sites); |
+ HValue* constructor_function, |
+ AllocationSiteOverrideMode override_mode); |
JSArrayBuilder(HGraphBuilder* builder, |
ElementsKind kind, |
@@ -1289,9 +1331,6 @@ class HGraphBuilder { |
int elements_size() const { |
return IsFastDoubleElementsKind(kind_) ? kDoubleSize : kPointerSize; |
} |
- HInstruction* AddInstruction(HInstruction* instr) { |
- return builder_->AddInstruction(instr); |
- } |
HGraphBuilder* builder() { return builder_; } |
HGraph* graph() { return builder_->graph(); } |
int initial_capacity() { |
@@ -1358,10 +1397,14 @@ class HGraphBuilder { |
HValue* BuildCloneShallowArray(HContext* context, |
HValue* boilerplate, |
+ HValue* allocation_site, |
AllocationSiteMode mode, |
ElementsKind kind, |
int length); |
+ HInstruction* BuildUnaryMathOp( |
+ HValue* value, Handle<Type> type, Token::Value token); |
+ |
void BuildCompareNil( |
HValue* value, |
Handle<Type> type, |
@@ -1383,7 +1426,6 @@ class HGraphBuilder { |
int no_side_effects_scope_count_; |
}; |
- |
class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { |
public: |
// A class encapsulating (lazily-allocated) break and continue blocks for |
@@ -1449,8 +1491,6 @@ class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { |
bool inline_bailout() { return inline_bailout_; } |
- void AddSoftDeoptimize(); |
- |
void Bailout(const char* reason); |
HBasicBlock* CreateJoin(HBasicBlock* first, |
@@ -1541,8 +1581,6 @@ class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { |
void VisitArithmeticExpression(BinaryOperation* expr); |
bool PreProcessOsrEntry(IterationStatement* statement); |
- // True iff. we are compiling for OSR and the statement is the entry. |
- bool HasOsrEntryAt(IterationStatement* statement); |
void VisitLoopBody(IterationStatement* stmt, |
HBasicBlock* loop_entry, |
BreakAndContinueInfo* break_info); |
@@ -1632,9 +1670,6 @@ class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { |
// to push them as outgoing parameters. |
template <class Instruction> HInstruction* PreProcessCall(Instruction* call); |
- static Representation ToRepresentation(TypeInfo info); |
- static Representation ToRepresentation(Handle<Type> type); |
- |
void SetUpScope(Scope* scope); |
virtual void VisitStatements(ZoneList<Statement*>* statements); |
@@ -1824,12 +1859,14 @@ class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { |
HInstruction* BuildFastLiteral(HValue* context, |
Handle<JSObject> boilerplate_object, |
Handle<JSObject> original_boilerplate_object, |
+ Handle<Object> allocation_site, |
int data_size, |
int pointer_size, |
AllocationSiteMode mode); |
void BuildEmitDeepCopy(Handle<JSObject> boilerplat_object, |
Handle<JSObject> object, |
+ Handle<Object> allocation_site, |
HInstruction* target, |
int* offset, |
HInstruction* data_target, |
@@ -1904,9 +1941,12 @@ class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { |
bool inline_bailout_; |
+ HOsrBuilder* osr_; |
+ |
friend class FunctionState; // Pushes and pops the state stack. |
friend class AstContext; // Pushes and pops the AST context stack. |
friend class KeyedLoadFastElementStub; |
+ friend class HOsrBuilder; |
DISALLOW_COPY_AND_ASSIGN(HOptimizedGraphBuilder); |
}; |