diff options
Diffstat (limited to 'deps/v8/src/hydrogen-instructions.h')
-rw-r--r-- | deps/v8/src/hydrogen-instructions.h | 570 |
1 files changed, 239 insertions, 331 deletions
diff --git a/deps/v8/src/hydrogen-instructions.h b/deps/v8/src/hydrogen-instructions.h index c863612cdd..8fd2aed0af 100644 --- a/deps/v8/src/hydrogen-instructions.h +++ b/deps/v8/src/hydrogen-instructions.h @@ -5,6 +5,7 @@ #ifndef V8_HYDROGEN_INSTRUCTIONS_H_ #define V8_HYDROGEN_INSTRUCTIONS_H_ +#include <cstring> #include <iosfwd> #include "src/v8.h" @@ -411,62 +412,6 @@ class DecompositionResult FINAL BASE_EMBEDDED { typedef EnumSet<GVNFlag, int32_t> GVNFlagSet; -// This class encapsulates encoding and decoding of sources positions from -// which hydrogen values originated. -// When FLAG_track_hydrogen_positions is set this object encodes the -// identifier of the inlining and absolute offset from the start of the -// inlined function. -// When the flag is not set we simply track absolute offset from the -// script start. -class HSourcePosition { - public: - HSourcePosition(const HSourcePosition& other) : value_(other.value_) { } - - static HSourcePosition Unknown() { - return HSourcePosition(RelocInfo::kNoPosition); - } - - bool IsUnknown() const { return value_ == RelocInfo::kNoPosition; } - - int position() const { return PositionField::decode(value_); } - void set_position(int position) { - if (FLAG_hydrogen_track_positions) { - value_ = static_cast<int>(PositionField::update(value_, position)); - } else { - value_ = position; - } - } - - int inlining_id() const { return InliningIdField::decode(value_); } - void set_inlining_id(int inlining_id) { - if (FLAG_hydrogen_track_positions) { - value_ = static_cast<int>(InliningIdField::update(value_, inlining_id)); - } - } - - int raw() const { return value_; } - - private: - typedef BitField<int, 0, 9> InliningIdField; - - // Offset from the start of the inlined function. - typedef BitField<int, 9, 23> PositionField; - - explicit HSourcePosition(int value) : value_(value) { } - - friend class HPositionInfo; - friend class LCodeGenBase; - - // If FLAG_hydrogen_track_positions is set contains bitfields InliningIdField - // and PositionField. - // Otherwise contains absolute offset from the script start. - int value_; -}; - - -std::ostream& operator<<(std::ostream& os, const HSourcePosition& p); - - class HValue : public ZoneObject { public: static const int kNoNumber = -1; @@ -562,10 +507,8 @@ class HValue : public ZoneObject { flags_(0) {} virtual ~HValue() {} - virtual HSourcePosition position() const { - return HSourcePosition::Unknown(); - } - virtual HSourcePosition operand_position(int index) const { + virtual SourcePosition position() const { return SourcePosition::Unknown(); } + virtual SourcePosition operand_position(int index) const { return position(); } @@ -951,98 +894,76 @@ std::ostream& operator<<(std::ostream& os, const TypeOf& v); std::ostream& operator<<(std::ostream& os, const ChangesOf& v); -#define DECLARE_INSTRUCTION_FACTORY_P0(I) \ - static I* New(Zone* zone, HValue* context) { \ - return new(zone) I(); \ -} +#define DECLARE_INSTRUCTION_FACTORY_P0(I) \ + static I* New(Isolate* isolate, Zone* zone, HValue* context) { \ + return new (zone) I(); \ + } -#define DECLARE_INSTRUCTION_FACTORY_P1(I, P1) \ - static I* New(Zone* zone, HValue* context, P1 p1) { \ - return new(zone) I(p1); \ +#define DECLARE_INSTRUCTION_FACTORY_P1(I, P1) \ + static I* New(Isolate* isolate, Zone* zone, HValue* context, P1 p1) { \ + return new (zone) I(p1); \ } #define DECLARE_INSTRUCTION_FACTORY_P2(I, P1, P2) \ - static I* New(Zone* zone, HValue* context, P1 p1, P2 p2) { \ - return new(zone) I(p1, p2); \ + static I* New(Isolate* isolate, Zone* zone, HValue* context, P1 p1, P2 p2) { \ + return new (zone) I(p1, p2); \ } -#define DECLARE_INSTRUCTION_FACTORY_P3(I, P1, P2, P3) \ - static I* New(Zone* zone, HValue* context, P1 p1, P2 p2, P3 p3) { \ - return new(zone) I(p1, p2, p3); \ +#define DECLARE_INSTRUCTION_FACTORY_P3(I, P1, P2, P3) \ + static I* New(Isolate* isolate, Zone* zone, HValue* context, P1 p1, P2 p2, \ + P3 p3) { \ + return new (zone) I(p1, p2, p3); \ } -#define DECLARE_INSTRUCTION_FACTORY_P4(I, P1, P2, P3, P4) \ - static I* New(Zone* zone, \ - HValue* context, \ - P1 p1, \ - P2 p2, \ - P3 p3, \ - P4 p4) { \ - return new(zone) I(p1, p2, p3, p4); \ +#define DECLARE_INSTRUCTION_FACTORY_P4(I, P1, P2, P3, P4) \ + static I* New(Isolate* isolate, Zone* zone, HValue* context, P1 p1, P2 p2, \ + P3 p3, P4 p4) { \ + return new (zone) I(p1, p2, p3, p4); \ } -#define DECLARE_INSTRUCTION_FACTORY_P5(I, P1, P2, P3, P4, P5) \ - static I* New(Zone* zone, \ - HValue* context, \ - P1 p1, \ - P2 p2, \ - P3 p3, \ - P4 p4, \ - P5 p5) { \ - return new(zone) I(p1, p2, p3, p4, p5); \ +#define DECLARE_INSTRUCTION_FACTORY_P5(I, P1, P2, P3, P4, P5) \ + static I* New(Isolate* isolate, Zone* zone, HValue* context, P1 p1, P2 p2, \ + P3 p3, P4 p4, P5 p5) { \ + return new (zone) I(p1, p2, p3, p4, p5); \ } -#define DECLARE_INSTRUCTION_FACTORY_P6(I, P1, P2, P3, P4, P5, P6) \ - static I* New(Zone* zone, \ - HValue* context, \ - P1 p1, \ - P2 p2, \ - P3 p3, \ - P4 p4, \ - P5 p5, \ - P6 p6) { \ - return new(zone) I(p1, p2, p3, p4, p5, p6); \ +#define DECLARE_INSTRUCTION_FACTORY_P6(I, P1, P2, P3, P4, P5, P6) \ + static I* New(Isolate* isolate, Zone* zone, HValue* context, P1 p1, P2 p2, \ + P3 p3, P4 p4, P5 p5, P6 p6) { \ + return new (zone) I(p1, p2, p3, p4, p5, p6); \ } -#define DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P0(I) \ - static I* New(Zone* zone, HValue* context) { \ - return new(zone) I(context); \ +#define DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P0(I) \ + static I* New(Isolate* isolate, Zone* zone, HValue* context) { \ + return new (zone) I(context); \ } -#define DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P1(I, P1) \ - static I* New(Zone* zone, HValue* context, P1 p1) { \ - return new(zone) I(context, p1); \ +#define DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P1(I, P1) \ + static I* New(Isolate* isolate, Zone* zone, HValue* context, P1 p1) { \ + return new (zone) I(context, p1); \ } #define DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P2(I, P1, P2) \ - static I* New(Zone* zone, HValue* context, P1 p1, P2 p2) { \ - return new(zone) I(context, p1, p2); \ + static I* New(Isolate* isolate, Zone* zone, HValue* context, P1 p1, P2 p2) { \ + return new (zone) I(context, p1, p2); \ } -#define DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P3(I, P1, P2, P3) \ - static I* New(Zone* zone, HValue* context, P1 p1, P2 p2, P3 p3) { \ - return new(zone) I(context, p1, p2, p3); \ +#define DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P3(I, P1, P2, P3) \ + static I* New(Isolate* isolate, Zone* zone, HValue* context, P1 p1, P2 p2, \ + P3 p3) { \ + return new (zone) I(context, p1, p2, p3); \ } -#define DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(I, P1, P2, P3, P4) \ - static I* New(Zone* zone, \ - HValue* context, \ - P1 p1, \ - P2 p2, \ - P3 p3, \ - P4 p4) { \ - return new(zone) I(context, p1, p2, p3, p4); \ +#define DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(I, P1, P2, P3, P4) \ + static I* New(Isolate* isolate, Zone* zone, HValue* context, P1 p1, P2 p2, \ + P3 p3, P4 p4) { \ + return new (zone) I(context, p1, p2, p3, p4); \ } -#define DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P5(I, P1, P2, P3, P4, P5) \ - static I* New(Zone* zone, \ - HValue* context, \ - P1 p1, \ - P2 p2, \ - P3 p3, \ - P4 p4, \ - P5 p5) { \ - return new(zone) I(context, p1, p2, p3, p4, p5); \ +#define DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P5(I, P1, P2, P3, P4, P5) \ + static I* New(Isolate* isolate, Zone* zone, HValue* context, P1 p1, P2 p2, \ + P3 p3, P4 p4, P5 p5) { \ + return new (zone) I(context, p1, p2, p3, p4, p5); \ } @@ -1057,14 +978,14 @@ class HPositionInfo { public: explicit HPositionInfo(int pos) : data_(TagPosition(pos)) { } - HSourcePosition position() const { + SourcePosition position() const { if (has_operand_positions()) { return operand_positions()[kInstructionPosIndex]; } - return HSourcePosition(static_cast<int>(UntagPosition(data_))); + return SourcePosition(static_cast<int>(UntagPosition(data_))); } - void set_position(HSourcePosition pos) { + void set_position(SourcePosition pos) { if (has_operand_positions()) { operand_positions()[kInstructionPosIndex] = pos; } else { @@ -1078,27 +999,26 @@ class HPositionInfo { } const int length = kFirstOperandPosIndex + operand_count; - HSourcePosition* positions = - zone->NewArray<HSourcePosition>(length); + SourcePosition* positions = zone->NewArray<SourcePosition>(length); for (int i = 0; i < length; i++) { - positions[i] = HSourcePosition::Unknown(); + positions[i] = SourcePosition::Unknown(); } - const HSourcePosition pos = position(); + const SourcePosition pos = position(); data_ = reinterpret_cast<intptr_t>(positions); set_position(pos); DCHECK(has_operand_positions()); } - HSourcePosition operand_position(int idx) const { + SourcePosition operand_position(int idx) const { if (!has_operand_positions()) { return position(); } return *operand_position_slot(idx); } - void set_operand_position(int idx, HSourcePosition pos) { + void set_operand_position(int idx, SourcePosition pos) { *operand_position_slot(idx) = pos; } @@ -1106,7 +1026,7 @@ class HPositionInfo { static const intptr_t kInstructionPosIndex = 0; static const intptr_t kFirstOperandPosIndex = 1; - HSourcePosition* operand_position_slot(int idx) const { + SourcePosition* operand_position_slot(int idx) const { DCHECK(has_operand_positions()); return &(operand_positions()[kFirstOperandPosIndex + idx]); } @@ -1115,9 +1035,9 @@ class HPositionInfo { return !IsTaggedPosition(data_); } - HSourcePosition* operand_positions() const { + SourcePosition* operand_positions() const { DCHECK(has_operand_positions()); - return reinterpret_cast<HSourcePosition*>(data_); + return reinterpret_cast<SourcePosition*>(data_); } static const intptr_t kPositionTag = 1; @@ -1165,23 +1085,23 @@ class HInstruction : public HValue { } // The position is a write-once variable. - HSourcePosition position() const OVERRIDE { - return HSourcePosition(position_.position()); + SourcePosition position() const OVERRIDE { + return SourcePosition(position_.position()); } bool has_position() const { return !position().IsUnknown(); } - void set_position(HSourcePosition position) { + void set_position(SourcePosition position) { DCHECK(!has_position()); DCHECK(!position.IsUnknown()); position_.set_position(position); } - HSourcePosition operand_position(int index) const OVERRIDE { - const HSourcePosition pos = position_.operand_position(index); + SourcePosition operand_position(int index) const OVERRIDE { + const SourcePosition pos = position_.operand_position(index); return pos.IsUnknown() ? position() : pos; } - void set_operand_position(Zone* zone, int index, HSourcePosition pos) { + void set_operand_position(Zone* zone, int index, SourcePosition pos) { DCHECK(0 <= index && index < OperandCount()); position_.ensure_storage_for_operand_positions(zone, OperandCount()); position_.set_operand_position(index, pos); @@ -1383,9 +1303,8 @@ class HGoto FINAL : public HTemplateControlInstruction<1, 0> { class HDeoptimize FINAL : public HTemplateControlInstruction<1, 0> { public: - static HDeoptimize* New(Zone* zone, - HValue* context, - const char* reason, + static HDeoptimize* New(Isolate* isolate, Zone* zone, HValue* context, + Deoptimizer::DeoptReason reason, Deoptimizer::BailoutType type, HBasicBlock* unreachable_continuation) { return new(zone) HDeoptimize(reason, type, unreachable_continuation); @@ -1400,20 +1319,20 @@ class HDeoptimize FINAL : public HTemplateControlInstruction<1, 0> { return Representation::None(); } - const char* reason() const { return reason_; } + Deoptimizer::DeoptReason reason() const { return reason_; } Deoptimizer::BailoutType type() { return type_; } DECLARE_CONCRETE_INSTRUCTION(Deoptimize) private: - explicit HDeoptimize(const char* reason, + explicit HDeoptimize(Deoptimizer::DeoptReason reason, Deoptimizer::BailoutType type, HBasicBlock* unreachable_continuation) : reason_(reason), type_(type) { SetSuccessorAt(0, unreachable_continuation); } - const char* reason_; + Deoptimizer::DeoptReason reason_; Deoptimizer::BailoutType type_; }; @@ -1636,7 +1555,8 @@ class HUseConst FINAL : public HUnaryOperation { class HForceRepresentation FINAL : public HTemplateInstruction<1> { public: - static HInstruction* New(Zone* zone, HValue* context, HValue* value, + static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, + HValue* value, Representation required_representation); HValue* value() const { return OperandAt(0); } @@ -2017,8 +1937,8 @@ class HConstant; class HEnterInlined FINAL : public HTemplateInstruction<0> { public: - static HEnterInlined* New(Zone* zone, HValue* context, BailoutId return_id, - Handle<JSFunction> closure, + static HEnterInlined* New(Isolate* isolate, Zone* zone, HValue* context, + BailoutId return_id, Handle<JSFunction> closure, HConstant* closure_context, int arguments_count, FunctionLiteral* function, InliningKind inlining_kind, Variable* arguments_var, @@ -2106,31 +2026,33 @@ class HLeaveInlined FINAL : public HTemplateInstruction<0> { class HPushArguments FINAL : public HInstruction { public: - static HPushArguments* New(Zone* zone, HValue* context) { + static HPushArguments* New(Isolate* isolate, Zone* zone, HValue* context) { return new(zone) HPushArguments(zone); } - static HPushArguments* New(Zone* zone, HValue* context, HValue* arg1) { + static HPushArguments* New(Isolate* isolate, Zone* zone, HValue* context, + HValue* arg1) { HPushArguments* instr = new(zone) HPushArguments(zone); instr->AddInput(arg1); return instr; } - static HPushArguments* New(Zone* zone, HValue* context, HValue* arg1, - HValue* arg2) { + static HPushArguments* New(Isolate* isolate, Zone* zone, HValue* context, + HValue* arg1, HValue* arg2) { HPushArguments* instr = new(zone) HPushArguments(zone); instr->AddInput(arg1); instr->AddInput(arg2); return instr; } - static HPushArguments* New(Zone* zone, HValue* context, HValue* arg1, - HValue* arg2, HValue* arg3) { + static HPushArguments* New(Isolate* isolate, Zone* zone, HValue* context, + HValue* arg1, HValue* arg2, HValue* arg3) { HPushArguments* instr = new(zone) HPushArguments(zone); instr->AddInput(arg1); instr->AddInput(arg2); instr->AddInput(arg3); return instr; } - static HPushArguments* New(Zone* zone, HValue* context, HValue* arg1, - HValue* arg2, HValue* arg3, HValue* arg4) { + static HPushArguments* New(Isolate* isolate, Zone* zone, HValue* context, + HValue* arg1, HValue* arg2, HValue* arg3, + HValue* arg4) { HPushArguments* instr = new(zone) HPushArguments(zone); instr->AddInput(arg1); instr->AddInput(arg2); @@ -2281,10 +2203,8 @@ class HBinaryCall : public HCall<2> { class HCallJSFunction FINAL : public HCall<1> { public: - static HCallJSFunction* New(Zone* zone, - HValue* context, - HValue* function, - int argument_count, + static HCallJSFunction* New(Isolate* isolate, Zone* zone, HValue* context, + HValue* function, int argument_count, bool pass_argument_count); HValue* function() const { return OperandAt(0); } @@ -2324,8 +2244,8 @@ enum CallMode { NORMAL_CALL, TAIL_CALL }; class HCallWithDescriptor FINAL : public HInstruction { public: - static HCallWithDescriptor* New(Zone* zone, HValue* context, HValue* target, - int argument_count, + static HCallWithDescriptor* New(Isolate* isolate, Zone* zone, HValue* context, + HValue* target, int argument_count, CallInterfaceDescriptor descriptor, const Vector<HValue*>& operands, CallMode call_mode = NORMAL_CALL) { @@ -2414,15 +2334,16 @@ class HInvokeFunction FINAL : public HBinaryCall { int argument_count) : HBinaryCall(context, function, argument_count), known_function_(known_function) { - formal_parameter_count_ = known_function.is_null() - ? 0 : known_function->shared()->formal_parameter_count(); + formal_parameter_count_ = + known_function.is_null() + ? 0 + : known_function->shared()->internal_formal_parameter_count(); has_stack_check_ = !known_function.is_null() && (known_function->code()->kind() == Code::FUNCTION || known_function->code()->kind() == Code::OPTIMIZED_FUNCTION); } - static HInvokeFunction* New(Zone* zone, - HValue* context, + static HInvokeFunction* New(Isolate* isolate, Zone* zone, HValue* context, HValue* function, Handle<JSFunction> known_function, int argument_count) { @@ -2457,22 +2378,36 @@ class HCallFunction FINAL : public HBinaryCall { DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P3( HCallFunction, HValue*, int, CallFunctionFlags); - HValue* context() { return first(); } - HValue* function() { return second(); } + HValue* context() const { return first(); } + HValue* function() const { return second(); } CallFunctionFlags function_flags() const { return function_flags_; } + FeedbackVectorICSlot slot() const { return slot_; } + Handle<TypeFeedbackVector> feedback_vector() const { + return feedback_vector_; + } + bool HasVectorAndSlot() const { return !feedback_vector_.is_null(); } + void SetVectorAndSlot(Handle<TypeFeedbackVector> vector, + FeedbackVectorICSlot slot) { + feedback_vector_ = vector; + slot_ = slot; + } + DECLARE_CONCRETE_INSTRUCTION(CallFunction) + std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT + int argument_delta() const OVERRIDE { return -argument_count(); } private: - HCallFunction(HValue* context, - HValue* function, - int argument_count, + HCallFunction(HValue* context, HValue* function, int argument_count, CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS) - : HBinaryCall(context, function, argument_count), function_flags_(flags) { - } + : HBinaryCall(context, function, argument_count), + function_flags_(flags), + slot_(FeedbackVectorICSlot::Invalid()) {} CallFunctionFlags function_flags_; + Handle<TypeFeedbackVector> feedback_vector_; + FeedbackVectorICSlot slot_; }; @@ -2583,10 +2518,8 @@ class HMapEnumLength FINAL : public HUnaryOperation { class HUnaryMathOperation FINAL : public HTemplateInstruction<2> { public: - static HInstruction* New(Zone* zone, - HValue* context, - HValue* value, - BuiltinFunctionId op); + static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, + HValue* value, BuiltinFunctionId op); HValue* context() const { return OperandAt(0); } HValue* value() const { return OperandAt(1); } @@ -2727,12 +2660,13 @@ class HLoadRoot FINAL : public HTemplateInstruction<0> { class HCheckMaps FINAL : public HTemplateInstruction<2> { public: - static HCheckMaps* New(Zone* zone, HValue* context, HValue* value, - Handle<Map> map, HValue* typecheck = NULL) { + static HCheckMaps* New(Isolate* isolate, Zone* zone, HValue* context, + HValue* value, Handle<Map> map, + HValue* typecheck = NULL) { return new(zone) HCheckMaps(value, new(zone) UniqueSet<Map>( Unique<Map>::CreateImmovable(map), zone), typecheck); } - static HCheckMaps* New(Zone* zone, HValue* context, + static HCheckMaps* New(Isolate* isolate, Zone* zone, HValue* context, HValue* value, SmallMapList* map_list, HValue* typecheck = NULL) { UniqueSet<Map>* maps = new(zone) UniqueSet<Map>(map_list->length(), zone); @@ -2862,9 +2796,9 @@ class HCheckMaps FINAL : public HTemplateInstruction<2> { class HCheckValue FINAL : public HUnaryOperation { public: - static HCheckValue* New(Zone* zone, HValue* context, + static HCheckValue* New(Isolate* isolate, Zone* zone, HValue* context, HValue* value, Handle<JSFunction> func) { - bool in_new_space = zone->isolate()->heap()->InNewSpace(*func); + bool in_new_space = isolate->heap()->InNewSpace(*func); // NOTE: We create an uninitialized Unique and initialize it later. // This is because a JSFunction can move due to GC during graph creation. // TODO(titzer): This is a migration crutch. Replace with some kind of @@ -2873,7 +2807,7 @@ class HCheckValue FINAL : public HUnaryOperation { HCheckValue* check = new(zone) HCheckValue(value, target, in_new_space); return check; } - static HCheckValue* New(Zone* zone, HValue* context, + static HCheckValue* New(Isolate* isolate, Zone* zone, HValue* context, HValue* value, Unique<HeapObject> target, bool object_in_new_space) { return new(zone) HCheckValue(value, target, object_in_new_space); @@ -3304,7 +3238,7 @@ class HPhi FINAL : public HValue { bool IsReceiver() const { return merged_index_ == 0; } bool HasMergedIndex() const { return merged_index_ != kInvalidMergedIndex; } - HSourcePosition position() const OVERRIDE; + SourcePosition position() const OVERRIDE; int merged_index() const { return merged_index_; } @@ -3415,7 +3349,8 @@ class HDematerializedObject : public HInstruction { class HArgumentsObject FINAL : public HDematerializedObject { public: - static HArgumentsObject* New(Zone* zone, HValue* context, int count) { + static HArgumentsObject* New(Isolate* isolate, Zone* zone, HValue* context, + int count) { return new(zone) HArgumentsObject(count, zone); } @@ -3483,19 +3418,21 @@ class HCapturedObject FINAL : public HDematerializedObject { class HConstant FINAL : public HTemplateInstruction<0> { public: + enum Special { kHoleNaN }; + + DECLARE_INSTRUCTION_FACTORY_P1(HConstant, Special); DECLARE_INSTRUCTION_FACTORY_P1(HConstant, int32_t); DECLARE_INSTRUCTION_FACTORY_P2(HConstant, int32_t, Representation); DECLARE_INSTRUCTION_FACTORY_P1(HConstant, double); DECLARE_INSTRUCTION_FACTORY_P1(HConstant, Handle<Object>); DECLARE_INSTRUCTION_FACTORY_P1(HConstant, ExternalReference); - static HConstant* CreateAndInsertAfter(Zone* zone, - HValue* context, - int32_t value, + static HConstant* CreateAndInsertAfter(Isolate* isolate, Zone* zone, + HValue* context, int32_t value, Representation representation, HInstruction* instruction) { - return instruction->Append(HConstant::New( - zone, context, value, representation)); + return instruction->Append( + HConstant::New(isolate, zone, context, value, representation)); } Handle<Map> GetMonomorphicJSObjectMap() OVERRIDE { @@ -3506,13 +3443,12 @@ class HConstant FINAL : public HTemplateInstruction<0> { return Handle<Map>(); } - static HConstant* CreateAndInsertBefore(Zone* zone, - HValue* context, - int32_t value, + static HConstant* CreateAndInsertBefore(Isolate* isolate, Zone* zone, + HValue* context, int32_t value, Representation representation, HInstruction* instruction) { - return instruction->Prepend(HConstant::New( - zone, context, value, representation)); + return instruction->Prepend( + HConstant::New(isolate, zone, context, value, representation)); } static HConstant* CreateAndInsertBefore(Zone* zone, @@ -3550,7 +3486,6 @@ class HConstant FINAL : public HTemplateInstruction<0> { bool IsSpecialDouble() const { return HasDoubleValue() && (bit_cast<int64_t>(double_value_) == bit_cast<int64_t>(-0.0) || - FixedDoubleArray::is_the_hole_nan(double_value_) || std::isnan(double_value_)); } @@ -3581,7 +3516,7 @@ class HConstant FINAL : public HTemplateInstruction<0> { std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT HConstant* CopyToRepresentation(Representation r, Zone* zone) const; Maybe<HConstant*> CopyToTruncatedInt32(Zone* zone); - Maybe<HConstant*> CopyToTruncatedNumber(Zone* zone); + Maybe<HConstant*> CopyToTruncatedNumber(Isolate* isolate, Zone* zone); bool HasInteger32Value() const { return HasInt32ValueField::decode(bit_field_); } @@ -3597,8 +3532,15 @@ class HConstant FINAL : public HTemplateInstruction<0> { DCHECK(HasDoubleValue()); return double_value_; } + uint64_t DoubleValueAsBits() const { + uint64_t bits; + DCHECK(HasDoubleValue()); + STATIC_ASSERT(sizeof(bits) == sizeof(double_value_)); + std::memcpy(&bits, &double_value_, sizeof(bits)); + return bits; + } bool IsTheHole() const { - if (HasDoubleValue() && FixedDoubleArray::is_the_hole_nan(double_value_)) { + if (HasDoubleValue() && DoubleValueAsBits() == kHoleNanInt64) { return true; } return object_.IsInitialized() && @@ -3661,7 +3603,11 @@ class HConstant FINAL : public HTemplateInstruction<0> { if (HasInteger32Value()) { return static_cast<intptr_t>(int32_value_); } else if (HasDoubleValue()) { - return static_cast<intptr_t>(bit_cast<int64_t>(double_value_)); + uint64_t bits = DoubleValueAsBits(); + if (sizeof(bits) > sizeof(intptr_t)) { + bits ^= (bits >> 32); + } + return static_cast<intptr_t>(bits); } else if (HasExternalReferenceValue()) { return reinterpret_cast<intptr_t>(external_reference_value_.address()); } else { @@ -3692,8 +3638,8 @@ class HConstant FINAL : public HTemplateInstruction<0> { int32_value_ == other_constant->int32_value_; } else if (HasDoubleValue()) { return other_constant->HasDoubleValue() && - bit_cast<int64_t>(double_value_) == - bit_cast<int64_t>(other_constant->double_value_); + std::memcmp(&double_value_, &other_constant->double_value_, + sizeof(double_value_)) == 0; } else if (HasExternalReferenceValue()) { return other_constant->HasExternalReferenceValue() && external_reference_value_ == @@ -3720,6 +3666,7 @@ class HConstant FINAL : public HTemplateInstruction<0> { private: friend class HGraph; + explicit HConstant(Special special); explicit HConstant(Handle<Object> handle, Representation r = Representation::None()); HConstant(int32_t value, @@ -3860,9 +3807,8 @@ class HBinaryOperation : public HTemplateInstruction<3> { return representation(); } - void SetOperandPositions(Zone* zone, - HSourcePosition left_pos, - HSourcePosition right_pos) { + void SetOperandPositions(Zone* zone, SourcePosition left_pos, + SourcePosition right_pos) { set_operand_position(zone, 1, left_pos); set_operand_position(zone, 2, right_pos); } @@ -4320,9 +4266,8 @@ class HCompareNumericAndBranch : public HTemplateControlInstruction<2, 2> { std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT - void SetOperandPositions(Zone* zone, - HSourcePosition left_pos, - HSourcePosition right_pos) { + void SetOperandPositions(Zone* zone, SourcePosition left_pos, + SourcePosition right_pos) { set_operand_position(zone, 0, left_pos); set_operand_position(zone, 1, right_pos); } @@ -4780,10 +4725,8 @@ class HInstanceOfKnownGlobal FINAL : public HTemplateInstruction<2> { class HPower FINAL : public HTemplateInstruction<2> { public: - static HInstruction* New(Zone* zone, - HValue* context, - HValue* left, - HValue* right); + static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, + HValue* left, HValue* right); HValue* left() { return OperandAt(0); } HValue* right() const { return OperandAt(1); } @@ -4819,10 +4762,8 @@ class HPower FINAL : public HTemplateInstruction<2> { class HAdd FINAL : public HArithmeticBinaryOperation { public: - static HInstruction* New(Zone* zone, - HValue* context, - HValue* left, - HValue* right); + static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, + HValue* left, HValue* right); // Add is only commutative if two integer values are added and not if two // tagged values are added (because it might be a String concatenation). @@ -4882,10 +4823,8 @@ class HAdd FINAL : public HArithmeticBinaryOperation { class HSub FINAL : public HArithmeticBinaryOperation { public: - static HInstruction* New(Zone* zone, - HValue* context, - HValue* left, - HValue* right); + static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, + HValue* left, HValue* right); HValue* Canonicalize() OVERRIDE; @@ -4915,16 +4854,12 @@ class HSub FINAL : public HArithmeticBinaryOperation { class HMul FINAL : public HArithmeticBinaryOperation { public: - static HInstruction* New(Zone* zone, - HValue* context, - HValue* left, - HValue* right); + static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, + HValue* left, HValue* right); - static HInstruction* NewImul(Zone* zone, - HValue* context, - HValue* left, - HValue* right) { - HInstruction* instr = HMul::New(zone, context, left, right); + static HInstruction* NewImul(Isolate* isolate, Zone* zone, HValue* context, + HValue* left, HValue* right) { + HInstruction* instr = HMul::New(isolate, zone, context, left, right); if (!instr->IsMul()) return instr; HMul* mul = HMul::cast(instr); // TODO(mstarzinger): Prevent bailout on minus zero for imul. @@ -4963,10 +4898,8 @@ class HMul FINAL : public HArithmeticBinaryOperation { class HMod FINAL : public HArithmeticBinaryOperation { public: - static HInstruction* New(Zone* zone, - HValue* context, - HValue* left, - HValue* right); + static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, + HValue* left, HValue* right); HValue* Canonicalize() OVERRIDE; @@ -4997,10 +4930,8 @@ class HMod FINAL : public HArithmeticBinaryOperation { class HDiv FINAL : public HArithmeticBinaryOperation { public: - static HInstruction* New(Zone* zone, - HValue* context, - HValue* left, - HValue* right); + static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, + HValue* left, HValue* right); HValue* Canonicalize() OVERRIDE; @@ -5031,11 +4962,8 @@ class HMathMinMax FINAL : public HArithmeticBinaryOperation { public: enum Operation { kMathMin, kMathMax }; - static HInstruction* New(Zone* zone, - HValue* context, - HValue* left, - HValue* right, - Operation op); + static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, + HValue* left, HValue* right, Operation op); Representation observed_input_representation(int index) OVERRIDE { return RequiredInputRepresentation(index); @@ -5079,11 +5007,8 @@ class HMathMinMax FINAL : public HArithmeticBinaryOperation { class HBitwise FINAL : public HBitwiseBinaryOperation { public: - static HInstruction* New(Zone* zone, - HValue* context, - Token::Value op, - HValue* left, - HValue* right); + static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, + Token::Value op, HValue* left, HValue* right); Token::Value op() const { return op_; } @@ -5141,10 +5066,8 @@ class HBitwise FINAL : public HBitwiseBinaryOperation { class HShl FINAL : public HBitwiseBinaryOperation { public: - static HInstruction* New(Zone* zone, - HValue* context, - HValue* left, - HValue* right); + static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, + HValue* left, HValue* right); Range* InferRange(Zone* zone) OVERRIDE; @@ -5172,10 +5095,8 @@ class HShl FINAL : public HBitwiseBinaryOperation { class HShr FINAL : public HBitwiseBinaryOperation { public: - static HInstruction* New(Zone* zone, - HValue* context, - HValue* left, - HValue* right); + static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, + HValue* left, HValue* right); bool TryDecompose(DecompositionResult* decomposition) OVERRIDE { if (right()->IsInteger32Constant()) { @@ -5211,10 +5132,8 @@ class HShr FINAL : public HBitwiseBinaryOperation { class HSar FINAL : public HBitwiseBinaryOperation { public: - static HInstruction* New(Zone* zone, - HValue* context, - HValue* left, - HValue* right); + static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, + HValue* left, HValue* right); bool TryDecompose(DecompositionResult* decomposition) OVERRIDE { if (right()->IsInteger32Constant()) { @@ -5250,10 +5169,8 @@ class HSar FINAL : public HBitwiseBinaryOperation { class HRor FINAL : public HBitwiseBinaryOperation { public: - static HInstruction* New(Zone* zone, - HValue* context, - HValue* left, - HValue* right) { + static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, + HValue* left, HValue* right) { return new(zone) HRor(context, left, right); } @@ -5589,14 +5506,10 @@ class HAllocate FINAL : public HTemplateInstruction<2> { ComputeFlags(NOT_TENURED, type1) == ComputeFlags(NOT_TENURED, type2); } - static HAllocate* New(Zone* zone, - HValue* context, - HValue* size, - HType type, - PretenureFlag pretenure_flag, - InstanceType instance_type, - Handle<AllocationSite> allocation_site = - Handle<AllocationSite>::null()) { + static HAllocate* New( + Isolate* isolate, Zone* zone, HValue* context, HValue* size, HType type, + PretenureFlag pretenure_flag, InstanceType instance_type, + Handle<AllocationSite> allocation_site = Handle<AllocationSite>::null()) { return new(zone) HAllocate(context, size, type, pretenure_flag, instance_type, allocation_site); } @@ -5771,10 +5684,8 @@ class HAllocate FINAL : public HTemplateInstruction<2> { class HStoreCodeEntry FINAL: public HTemplateInstruction<2> { public: - static HStoreCodeEntry* New(Zone* zone, - HValue* context, - HValue* function, - HValue* code) { + static HStoreCodeEntry* New(Isolate* isolate, Zone* zone, HValue* context, + HValue* function, HValue* code) { return new(zone) HStoreCodeEntry(function, code); } @@ -5797,11 +5708,9 @@ class HStoreCodeEntry FINAL: public HTemplateInstruction<2> { class HInnerAllocatedObject FINAL : public HTemplateInstruction<2> { public: - static HInnerAllocatedObject* New(Zone* zone, - HValue* context, - HValue* value, - HValue* offset, - HType type) { + static HInnerAllocatedObject* New(Isolate* isolate, Zone* zone, + HValue* context, HValue* value, + HValue* offset, HType type) { return new(zone) HInnerAllocatedObject(value, offset, type); } @@ -6260,6 +6169,10 @@ class HObjectAccess FINAL { return HObjectAccess(kInobject, WeakCell::kValueOffset); } + static HObjectAccess ForWeakCellNext() { + return HObjectAccess(kInobject, WeakCell::kNextOffset); + } + static HObjectAccess ForAllocationMementoSite() { return HObjectAccess(kInobject, AllocationMemento::kAllocationSiteOffset); } @@ -7002,6 +6915,14 @@ class HStoreNamedField FINAL : public HTemplateInstruction<3> { SetChangesFlag(kMaps); } + void MarkReceiverAsCell() { + bit_field_ = ReceiverIsCellField::update(bit_field_, true); + } + + bool receiver_is_cell() const { + return ReceiverIsCellField::decode(bit_field_); + } + bool NeedsWriteBarrier() const { DCHECK(!field_representation().IsDouble() || (FLAG_unbox_double_fields && access_.IsInobject()) || @@ -7010,6 +6931,7 @@ class HStoreNamedField FINAL : public HTemplateInstruction<3> { if (field_representation().IsSmi()) return false; if (field_representation().IsInteger32()) return false; if (field_representation().IsExternal()) return false; + if (receiver_is_cell()) return false; return StoringValueNeedsWriteBarrier(value()) && ReceiverObjectNeedsWriteBarrier(object(), value(), dominator()); } @@ -7069,6 +6991,7 @@ class HStoreNamedField FINAL : public HTemplateInstruction<3> { class HasTransitionField : public BitField<bool, 0, 1> {}; class StoreModeField : public BitField<StoreFieldOrKeyedMode, 1, 1> {}; + class ReceiverIsCellField : public BitField<bool, 2, 1> {}; HObjectAccess access_; HValue* dominator_; @@ -7080,12 +7003,12 @@ class HStoreNamedGeneric FINAL : public HTemplateInstruction<3> { public: DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(HStoreNamedGeneric, HValue*, Handle<String>, HValue*, - StrictMode); + LanguageMode); HValue* object() const { return OperandAt(0); } HValue* value() const { return OperandAt(1); } HValue* context() const { return OperandAt(2); } Handle<String> name() const { return name_; } - StrictMode strict_mode() const { return strict_mode_; } + LanguageMode language_mode() const { return language_mode_; } std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT @@ -7096,13 +7019,9 @@ class HStoreNamedGeneric FINAL : public HTemplateInstruction<3> { DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric) private: - HStoreNamedGeneric(HValue* context, - HValue* object, - Handle<String> name, - HValue* value, - StrictMode strict_mode) - : name_(name), - strict_mode_(strict_mode) { + HStoreNamedGeneric(HValue* context, HValue* object, Handle<String> name, + HValue* value, LanguageMode language_mode) + : name_(name), language_mode_(language_mode) { SetOperandAt(0, object); SetOperandAt(1, value); SetOperandAt(2, context); @@ -7110,7 +7029,7 @@ class HStoreNamedGeneric FINAL : public HTemplateInstruction<3> { } Handle<String> name_; - StrictMode strict_mode_; + LanguageMode language_mode_; }; @@ -7301,13 +7220,13 @@ class HStoreKeyed FINAL class HStoreKeyedGeneric FINAL : public HTemplateInstruction<4> { public: DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(HStoreKeyedGeneric, HValue*, - HValue*, HValue*, StrictMode); + HValue*, HValue*, LanguageMode); HValue* object() const { return OperandAt(0); } HValue* key() const { return OperandAt(1); } HValue* value() const { return OperandAt(2); } HValue* context() const { return OperandAt(3); } - StrictMode strict_mode() const { return strict_mode_; } + LanguageMode language_mode() const { return language_mode_; } Representation RequiredInputRepresentation(int index) OVERRIDE { // tagged[tagged] = tagged @@ -7319,12 +7238,9 @@ class HStoreKeyedGeneric FINAL : public HTemplateInstruction<4> { DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric) private: - HStoreKeyedGeneric(HValue* context, - HValue* object, - HValue* key, - HValue* value, - StrictMode strict_mode) - : strict_mode_(strict_mode) { + HStoreKeyedGeneric(HValue* context, HValue* object, HValue* key, + HValue* value, LanguageMode language_mode) + : language_mode_(language_mode) { SetOperandAt(0, object); SetOperandAt(1, key); SetOperandAt(2, value); @@ -7332,15 +7248,14 @@ class HStoreKeyedGeneric FINAL : public HTemplateInstruction<4> { SetAllSideEffects(); } - StrictMode strict_mode_; + LanguageMode language_mode_; }; class HTransitionElementsKind FINAL : public HTemplateInstruction<2> { public: - inline static HTransitionElementsKind* New(Zone* zone, - HValue* context, - HValue* object, + inline static HTransitionElementsKind* New(Isolate* isolate, Zone* zone, + HValue* context, HValue* object, Handle<Map> original_map, Handle<Map> transitioned_map) { return new(zone) HTransitionElementsKind(context, object, @@ -7409,14 +7324,11 @@ class HTransitionElementsKind FINAL : public HTemplateInstruction<2> { class HStringAdd FINAL : public HBinaryOperation { public: - static HInstruction* New(Zone* zone, - HValue* context, - HValue* left, - HValue* right, - PretenureFlag pretenure_flag = NOT_TENURED, - StringAddFlags flags = STRING_ADD_CHECK_BOTH, - Handle<AllocationSite> allocation_site = - Handle<AllocationSite>::null()); + static HInstruction* New( + Isolate* isolate, Zone* zone, HValue* context, HValue* left, + HValue* right, PretenureFlag pretenure_flag = NOT_TENURED, + StringAddFlags flags = STRING_ADD_CHECK_BOTH, + Handle<AllocationSite> allocation_site = Handle<AllocationSite>::null()); StringAddFlags flags() const { return flags_; } PretenureFlag pretenure_flag() const { return pretenure_flag_; } @@ -7510,8 +7422,7 @@ class HStringCharCodeAt FINAL : public HTemplateInstruction<3> { class HStringCharFromCode FINAL : public HTemplateInstruction<2> { public: - static HInstruction* New(Zone* zone, - HValue* context, + static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, HValue* char_code); Representation RequiredInputRepresentation(int index) OVERRIDE { @@ -7630,12 +7541,10 @@ class HFunctionLiteral FINAL : public HTemplateInstruction<1> { bool has_no_literals() const { return HasNoLiteralsField::decode(bit_field_); } - bool is_arrow() const { return IsArrowFunction(kind()); } - bool is_generator() const { return IsGeneratorFunction(kind()); } - bool is_concise_method() const { return IsConciseMethod(kind()); } - bool is_default_constructor() const { return IsDefaultConstructor(kind()); } FunctionKind kind() const { return FunctionKindField::decode(bit_field_); } - StrictMode strict_mode() const { return StrictModeField::decode(bit_field_); } + LanguageMode language_mode() const { + return LanguageModeField::decode(bit_field_); + } private: HFunctionLiteral(HValue* context, Handle<SharedFunctionInfo> shared, @@ -7645,7 +7554,7 @@ class HFunctionLiteral FINAL : public HTemplateInstruction<1> { bit_field_(FunctionKindField::encode(shared->kind()) | PretenureField::encode(pretenure) | HasNoLiteralsField::encode(shared->num_literals() == 0) | - StrictModeField::encode(shared->strict_mode())) { + LanguageModeField::encode(shared->language_mode())) { SetOperandAt(0, context); set_representation(Representation::Tagged()); SetChangesFlag(kNewSpacePromotion); @@ -7653,10 +7562,11 @@ class HFunctionLiteral FINAL : public HTemplateInstruction<1> { bool IsDeletable() const OVERRIDE { return true; } - class FunctionKindField : public BitField<FunctionKind, 0, 4> {}; - class PretenureField : public BitField<bool, 5, 1> {}; - class HasNoLiteralsField : public BitField<bool, 6, 1> {}; - class StrictModeField : public BitField<StrictMode, 7, 1> {}; + class FunctionKindField : public BitField<FunctionKind, 0, 6> {}; + class PretenureField : public BitField<bool, 6, 1> {}; + class HasNoLiteralsField : public BitField<bool, 7, 1> {}; + STATIC_ASSERT(LANGUAGE_END == 3); + class LanguageModeField : public BitField<LanguageMode, 8, 2> {}; Handle<SharedFunctionInfo> shared_info_; uint32_t bit_field_; @@ -7761,10 +7671,8 @@ class HDateField FINAL : public HUnaryOperation { class HSeqStringGetChar FINAL : public HTemplateInstruction<2> { public: - static HInstruction* New(Zone* zone, - HValue* context, - String::Encoding encoding, - HValue* string, + static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, + String::Encoding encoding, HValue* string, HValue* index); Representation RequiredInputRepresentation(int index) OVERRIDE { |