Commit cc1458a9 authored by loislo's avatar loislo Committed by Commit bot

CpuProfile: rename HSourcePosition to SourcePosition and move it to compiler.*

Fix CompilationInfo::TraceInlinedFunction argument.
Fix leaked CodeTracer in Isolate

BUG=452067
LOG=n

Review URL: https://codereview.chromium.org/928343003

Cr-Commit-Position: refs/heads/master@{#26689}
parent 74876fd6
...@@ -35,6 +35,17 @@ namespace v8 { ...@@ -35,6 +35,17 @@ namespace v8 {
namespace internal { namespace internal {
std::ostream& operator<<(std::ostream& os, const SourcePosition& p) {
if (p.IsUnknown()) {
return os << "<?>";
} else if (FLAG_hydrogen_track_positions) {
return os << "<" << p.inlining_id() << ":" << p.position() << ">";
} else {
return os << "<0:" << p.raw() << ">";
}
}
ScriptData::ScriptData(const byte* data, int length) ScriptData::ScriptData(const byte* data, int length)
: owns_data_(false), rejected_(false), data_(data), length_(length) { : owns_data_(false), rejected_(false), data_(data), length_(length) {
if (!IsAligned(reinterpret_cast<intptr_t>(data), kPointerAlignment)) { if (!IsAligned(reinterpret_cast<intptr_t>(data), kPointerAlignment)) {
...@@ -324,7 +335,7 @@ bool CompilationInfo::is_simple_parameter_list() { ...@@ -324,7 +335,7 @@ bool CompilationInfo::is_simple_parameter_list() {
int CompilationInfo::TraceInlinedFunction(Handle<SharedFunctionInfo> shared, int CompilationInfo::TraceInlinedFunction(Handle<SharedFunctionInfo> shared,
int raw_position) { SourcePosition position) {
if (!FLAG_hydrogen_track_positions) { if (!FLAG_hydrogen_track_positions) {
return 0; return 0;
} }
...@@ -369,7 +380,6 @@ int CompilationInfo::TraceInlinedFunction(Handle<SharedFunctionInfo> shared, ...@@ -369,7 +380,6 @@ int CompilationInfo::TraceInlinedFunction(Handle<SharedFunctionInfo> shared,
if (inline_id != 0) { if (inline_id != 0) {
CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer());
OFStream os(tracing_scope.file()); OFStream os(tracing_scope.file());
HSourcePosition position = HSourcePosition::FromRaw(raw_position);
os << "INLINE (" << shared->DebugName()->ToCString().get() << ") id{" os << "INLINE (" << shared->DebugName()->ToCString().get() << ") id{"
<< optimization_id() << "," << id << "} AS " << inline_id << " AT " << optimization_id() << "," << id << "} AS " << inline_id << " AT "
<< position << std::endl; << position << std::endl;
......
...@@ -30,6 +30,62 @@ struct OffsetRange { ...@@ -30,6 +30,62 @@ struct OffsetRange {
}; };
// 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 SourcePosition {
public:
SourcePosition(const SourcePosition& other) : value_(other.value_) {}
static SourcePosition Unknown() {
return SourcePosition(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 SourcePosition(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 SourcePosition& p);
class InlinedFunctionInfo { class InlinedFunctionInfo {
public: public:
explicit InlinedFunctionInfo(Handle<SharedFunctionInfo> shared) explicit InlinedFunctionInfo(Handle<SharedFunctionInfo> shared)
...@@ -403,7 +459,8 @@ class CompilationInfo { ...@@ -403,7 +459,8 @@ class CompilationInfo {
List<int>* inlining_id_to_function_id() { List<int>* inlining_id_to_function_id() {
return inlining_id_to_function_id_; return inlining_id_to_function_id_;
} }
int TraceInlinedFunction(Handle<SharedFunctionInfo> shared, int raw_position); int TraceInlinedFunction(Handle<SharedFunctionInfo> shared,
SourcePosition position);
Handle<Foreign> object_wrapper() { Handle<Foreign> object_wrapper() {
if (object_wrapper_.is_null()) { if (object_wrapper_.is_null()) {
......
...@@ -622,17 +622,6 @@ void HValue::ComputeInitialRange(Zone* zone) { ...@@ -622,17 +622,6 @@ void HValue::ComputeInitialRange(Zone* zone) {
} }
std::ostream& operator<<(std::ostream& os, const HSourcePosition& p) {
if (p.IsUnknown()) {
return os << "<?>";
} else if (FLAG_hydrogen_track_positions) {
return os << "<" << p.inlining_id() << ":" << p.position() << ">";
} else {
return os << "<0:" << p.raw() << ">";
}
}
std::ostream& HInstruction::PrintTo(std::ostream& os) const { // NOLINT std::ostream& HInstruction::PrintTo(std::ostream& os) const { // NOLINT
os << Mnemonic() << " "; os << Mnemonic() << " ";
PrintDataTo(os) << ChangesOf(this) << TypeOf(this); PrintDataTo(os) << ChangesOf(this) << TypeOf(this);
...@@ -1816,9 +1805,7 @@ Range* HConstant::InferRange(Zone* zone) { ...@@ -1816,9 +1805,7 @@ Range* HConstant::InferRange(Zone* zone) {
} }
HSourcePosition HPhi::position() const { SourcePosition HPhi::position() const { return block()->first()->position(); }
return block()->first()->position();
}
Range* HPhi::InferRange(Zone* zone) { Range* HPhi::InferRange(Zone* zone) {
......
...@@ -412,65 +412,6 @@ class DecompositionResult FINAL BASE_EMBEDDED { ...@@ -412,65 +412,6 @@ class DecompositionResult FINAL BASE_EMBEDDED {
typedef EnumSet<GVNFlag, int32_t> GVNFlagSet; 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);
}
static HSourcePosition FromRaw(int raw_value) {
return HSourcePosition(raw_value);
}
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 { class HValue : public ZoneObject {
public: public:
static const int kNoNumber = -1; static const int kNoNumber = -1;
...@@ -566,10 +507,8 @@ class HValue : public ZoneObject { ...@@ -566,10 +507,8 @@ class HValue : public ZoneObject {
flags_(0) {} flags_(0) {}
virtual ~HValue() {} virtual ~HValue() {}
virtual HSourcePosition position() const { virtual SourcePosition position() const { return SourcePosition::Unknown(); }
return HSourcePosition::Unknown(); virtual SourcePosition operand_position(int index) const {
}
virtual HSourcePosition operand_position(int index) const {
return position(); return position();
} }
...@@ -1039,14 +978,14 @@ class HPositionInfo { ...@@ -1039,14 +978,14 @@ class HPositionInfo {
public: public:
explicit HPositionInfo(int pos) : data_(TagPosition(pos)) { } explicit HPositionInfo(int pos) : data_(TagPosition(pos)) { }
HSourcePosition position() const { SourcePosition position() const {
if (has_operand_positions()) { if (has_operand_positions()) {
return operand_positions()[kInstructionPosIndex]; 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()) { if (has_operand_positions()) {
operand_positions()[kInstructionPosIndex] = pos; operand_positions()[kInstructionPosIndex] = pos;
} else { } else {
...@@ -1060,27 +999,26 @@ class HPositionInfo { ...@@ -1060,27 +999,26 @@ class HPositionInfo {
} }
const int length = kFirstOperandPosIndex + operand_count; const int length = kFirstOperandPosIndex + operand_count;
HSourcePosition* positions = SourcePosition* positions = zone->NewArray<SourcePosition>(length);
zone->NewArray<HSourcePosition>(length);
for (int i = 0; i < length; i++) { 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); data_ = reinterpret_cast<intptr_t>(positions);
set_position(pos); set_position(pos);
DCHECK(has_operand_positions()); DCHECK(has_operand_positions());
} }
HSourcePosition operand_position(int idx) const { SourcePosition operand_position(int idx) const {
if (!has_operand_positions()) { if (!has_operand_positions()) {
return position(); return position();
} }
return *operand_position_slot(idx); 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; *operand_position_slot(idx) = pos;
} }
...@@ -1088,7 +1026,7 @@ class HPositionInfo { ...@@ -1088,7 +1026,7 @@ class HPositionInfo {
static const intptr_t kInstructionPosIndex = 0; static const intptr_t kInstructionPosIndex = 0;
static const intptr_t kFirstOperandPosIndex = 1; static const intptr_t kFirstOperandPosIndex = 1;
HSourcePosition* operand_position_slot(int idx) const { SourcePosition* operand_position_slot(int idx) const {
DCHECK(has_operand_positions()); DCHECK(has_operand_positions());
return &(operand_positions()[kFirstOperandPosIndex + idx]); return &(operand_positions()[kFirstOperandPosIndex + idx]);
} }
...@@ -1097,9 +1035,9 @@ class HPositionInfo { ...@@ -1097,9 +1035,9 @@ class HPositionInfo {
return !IsTaggedPosition(data_); return !IsTaggedPosition(data_);
} }
HSourcePosition* operand_positions() const { SourcePosition* operand_positions() const {
DCHECK(has_operand_positions()); DCHECK(has_operand_positions());
return reinterpret_cast<HSourcePosition*>(data_); return reinterpret_cast<SourcePosition*>(data_);
} }
static const intptr_t kPositionTag = 1; static const intptr_t kPositionTag = 1;
...@@ -1147,23 +1085,23 @@ class HInstruction : public HValue { ...@@ -1147,23 +1085,23 @@ class HInstruction : public HValue {
} }
// The position is a write-once variable. // The position is a write-once variable.
HSourcePosition position() const OVERRIDE { SourcePosition position() const OVERRIDE {
return HSourcePosition(position_.position()); return SourcePosition(position_.position());
} }
bool has_position() const { bool has_position() const {
return !position().IsUnknown(); return !position().IsUnknown();
} }
void set_position(HSourcePosition position) { void set_position(SourcePosition position) {
DCHECK(!has_position()); DCHECK(!has_position());
DCHECK(!position.IsUnknown()); DCHECK(!position.IsUnknown());
position_.set_position(position); position_.set_position(position);
} }
HSourcePosition operand_position(int index) const OVERRIDE { SourcePosition operand_position(int index) const OVERRIDE {
const HSourcePosition pos = position_.operand_position(index); const SourcePosition pos = position_.operand_position(index);
return pos.IsUnknown() ? position() : pos; 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()); DCHECK(0 <= index && index < OperandCount());
position_.ensure_storage_for_operand_positions(zone, OperandCount()); position_.ensure_storage_for_operand_positions(zone, OperandCount());
position_.set_operand_position(index, pos); position_.set_operand_position(index, pos);
...@@ -3300,7 +3238,7 @@ class HPhi FINAL : public HValue { ...@@ -3300,7 +3238,7 @@ class HPhi FINAL : public HValue {
bool IsReceiver() const { return merged_index_ == 0; } bool IsReceiver() const { return merged_index_ == 0; }
bool HasMergedIndex() const { return merged_index_ != kInvalidMergedIndex; } bool HasMergedIndex() const { return merged_index_ != kInvalidMergedIndex; }
HSourcePosition position() const OVERRIDE; SourcePosition position() const OVERRIDE;
int merged_index() const { return merged_index_; } int merged_index() const { return merged_index_; }
...@@ -3869,9 +3807,8 @@ class HBinaryOperation : public HTemplateInstruction<3> { ...@@ -3869,9 +3807,8 @@ class HBinaryOperation : public HTemplateInstruction<3> {
return representation(); return representation();
} }
void SetOperandPositions(Zone* zone, void SetOperandPositions(Zone* zone, SourcePosition left_pos,
HSourcePosition left_pos, SourcePosition right_pos) {
HSourcePosition right_pos) {
set_operand_position(zone, 1, left_pos); set_operand_position(zone, 1, left_pos);
set_operand_position(zone, 2, right_pos); set_operand_position(zone, 2, right_pos);
} }
...@@ -4329,9 +4266,8 @@ class HCompareNumericAndBranch : public HTemplateControlInstruction<2, 2> { ...@@ -4329,9 +4266,8 @@ class HCompareNumericAndBranch : public HTemplateControlInstruction<2, 2> {
std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
void SetOperandPositions(Zone* zone, void SetOperandPositions(Zone* zone, SourcePosition left_pos,
HSourcePosition left_pos, SourcePosition right_pos) {
HSourcePosition right_pos) {
set_operand_position(zone, 0, left_pos); set_operand_position(zone, 0, left_pos);
set_operand_position(zone, 1, right_pos); set_operand_position(zone, 1, right_pos);
} }
......
...@@ -129,8 +129,7 @@ void HBasicBlock::RemovePhi(HPhi* phi) { ...@@ -129,8 +129,7 @@ void HBasicBlock::RemovePhi(HPhi* phi) {
} }
void HBasicBlock::AddInstruction(HInstruction* instr, void HBasicBlock::AddInstruction(HInstruction* instr, SourcePosition position) {
HSourcePosition position) {
DCHECK(!IsStartBlock() || !IsFinished()); DCHECK(!IsStartBlock() || !IsFinished());
DCHECK(!instr->IsLinked()); DCHECK(!instr->IsLinked());
DCHECK(!IsFinished()); DCHECK(!IsFinished());
...@@ -199,7 +198,7 @@ HSimulate* HBasicBlock::CreateSimulate(BailoutId ast_id, ...@@ -199,7 +198,7 @@ HSimulate* HBasicBlock::CreateSimulate(BailoutId ast_id,
} }
void HBasicBlock::Finish(HControlInstruction* end, HSourcePosition position) { void HBasicBlock::Finish(HControlInstruction* end, SourcePosition position) {
DCHECK(!IsFinished()); DCHECK(!IsFinished());
AddInstruction(end, position); AddInstruction(end, position);
end_ = end; end_ = end;
...@@ -209,10 +208,8 @@ void HBasicBlock::Finish(HControlInstruction* end, HSourcePosition position) { ...@@ -209,10 +208,8 @@ void HBasicBlock::Finish(HControlInstruction* end, HSourcePosition position) {
} }
void HBasicBlock::Goto(HBasicBlock* block, void HBasicBlock::Goto(HBasicBlock* block, SourcePosition position,
HSourcePosition position, FunctionState* state, bool add_simulate) {
FunctionState* state,
bool add_simulate) {
bool drop_extra = state != NULL && bool drop_extra = state != NULL &&
state->inlining_kind() == NORMAL_RETURN; state->inlining_kind() == NORMAL_RETURN;
...@@ -231,9 +228,8 @@ void HBasicBlock::Goto(HBasicBlock* block, ...@@ -231,9 +228,8 @@ void HBasicBlock::Goto(HBasicBlock* block,
} }
void HBasicBlock::AddLeaveInlined(HValue* return_value, void HBasicBlock::AddLeaveInlined(HValue* return_value, FunctionState* state,
FunctionState* state, SourcePosition position) {
HSourcePosition position) {
HBasicBlock* target = state->function_return(); HBasicBlock* target = state->function_return();
bool drop_extra = state->inlining_kind() == NORMAL_RETURN; bool drop_extra = state->inlining_kind() == NORMAL_RETURN;
...@@ -1029,7 +1025,7 @@ void HGraphBuilder::IfBuilder::End() { ...@@ -1029,7 +1025,7 @@ void HGraphBuilder::IfBuilder::End() {
if (current->deopt_ && current->block_ != NULL) { if (current->deopt_ && current->block_ != NULL) {
current->block_->FinishExit( current->block_->FinishExit(
HAbnormalExit::New(builder()->isolate(), builder()->zone(), NULL), HAbnormalExit::New(builder()->isolate(), builder()->zone(), NULL),
HSourcePosition::Unknown()); SourcePosition::Unknown());
} }
current = current->next_; current = current->next_;
} }
...@@ -3422,7 +3418,7 @@ HBasicBlock* HOptimizedGraphBuilder::BuildLoopEntry( ...@@ -3422,7 +3418,7 @@ HBasicBlock* HOptimizedGraphBuilder::BuildLoopEntry(
void HBasicBlock::FinishExit(HControlInstruction* instruction, void HBasicBlock::FinishExit(HControlInstruction* instruction,
HSourcePosition position) { SourcePosition position) {
Finish(instruction, position); Finish(instruction, position);
ClearEnvironment(); ClearEnvironment();
} }
...@@ -3457,8 +3453,7 @@ HGraph::HGraph(CompilationInfo* info) ...@@ -3457,8 +3453,7 @@ HGraph::HGraph(CompilationInfo* info)
start_environment_ = new (zone_) start_environment_ = new (zone_)
HEnvironment(zone_, descriptor.GetEnvironmentParameterCount()); HEnvironment(zone_, descriptor.GetEnvironmentParameterCount());
} else { } else {
info->TraceInlinedFunction(info->shared_info(), info->TraceInlinedFunction(info->shared_info(), SourcePosition::Unknown());
HSourcePosition::Unknown().raw());
start_environment_ = start_environment_ =
new(zone_) HEnvironment(NULL, info->scope(), info->closure(), zone_); new(zone_) HEnvironment(NULL, info->scope(), info->closure(), zone_);
} }
...@@ -3486,7 +3481,7 @@ void HGraph::FinalizeUniqueness() { ...@@ -3486,7 +3481,7 @@ void HGraph::FinalizeUniqueness() {
} }
int HGraph::SourcePositionToScriptPosition(HSourcePosition pos) { int HGraph::SourcePositionToScriptPosition(SourcePosition pos) {
if (!FLAG_hydrogen_track_positions || pos.IsUnknown()) { if (!FLAG_hydrogen_track_positions || pos.IsUnknown()) {
return pos.raw(); return pos.raw();
} }
...@@ -3880,8 +3875,7 @@ void HGraph::CollectPhis() { ...@@ -3880,8 +3875,7 @@ void HGraph::CollectPhis() {
// Implementation of utility class to encapsulate the translation state for // Implementation of utility class to encapsulate the translation state for
// a (possibly inlined) function. // a (possibly inlined) function.
FunctionState::FunctionState(HOptimizedGraphBuilder* owner, FunctionState::FunctionState(HOptimizedGraphBuilder* owner,
CompilationInfo* info, CompilationInfo* info, InliningKind inlining_kind,
InliningKind inlining_kind,
int inlining_id) int inlining_id)
: owner_(owner), : owner_(owner),
compilation_info_(info), compilation_info_(info),
...@@ -3893,7 +3887,7 @@ FunctionState::FunctionState(HOptimizedGraphBuilder* owner, ...@@ -3893,7 +3887,7 @@ FunctionState::FunctionState(HOptimizedGraphBuilder* owner,
arguments_object_(NULL), arguments_object_(NULL),
arguments_elements_(NULL), arguments_elements_(NULL),
inlining_id_(inlining_id), inlining_id_(inlining_id),
outer_source_position_(HSourcePosition::Unknown()), outer_source_position_(SourcePosition::Unknown()),
outer_(owner->function_state()) { outer_(owner->function_state()) {
if (outer_ != NULL) { if (outer_ != NULL) {
// State for an inline function. // State for an inline function.
...@@ -7816,10 +7810,9 @@ int HOptimizedGraphBuilder::InliningAstSize(Handle<JSFunction> target) { ...@@ -7816,10 +7810,9 @@ int HOptimizedGraphBuilder::InliningAstSize(Handle<JSFunction> target) {
bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target, bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target,
int arguments_count, int arguments_count,
HValue* implicit_return_value, HValue* implicit_return_value,
BailoutId ast_id, BailoutId ast_id, BailoutId return_id,
BailoutId return_id,
InliningKind inlining_kind, InliningKind inlining_kind,
HSourcePosition position) { SourcePosition position) {
int nodes_added = InliningAstSize(target); int nodes_added = InliningAstSize(target);
if (nodes_added == kNotInlinable) return false; if (nodes_added == kNotInlinable) return false;
...@@ -7931,8 +7924,7 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target, ...@@ -7931,8 +7924,7 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target,
DCHECK(target_shared->has_deoptimization_support()); DCHECK(target_shared->has_deoptimization_support());
AstTyper::Run(&target_info); AstTyper::Run(&target_info);
int function_id = int function_id = top_info()->TraceInlinedFunction(target_shared, position);
top_info()->TraceInlinedFunction(target_shared, position.raw());
// Save the pending call context. Set up new one for the inlined function. // Save the pending call context. Set up new one for the inlined function.
// The function state is new-allocated because we need to delete it // The function state is new-allocated because we need to delete it
...@@ -10939,15 +10931,9 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { ...@@ -10939,15 +10931,9 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction( HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction(
Token::Value op, Token::Value op, HValue* left, HValue* right, Type* left_type,
HValue* left, Type* right_type, Type* combined_type, SourcePosition left_position,
HValue* right, SourcePosition right_position, PushBeforeSimulateBehavior push_sim_result,
Type* left_type,
Type* right_type,
Type* combined_type,
HSourcePosition left_position,
HSourcePosition right_position,
PushBeforeSimulateBehavior push_sim_result,
BailoutId bailout_id) { BailoutId bailout_id) {
// Cases handled below depend on collected type feedback. They should // Cases handled below depend on collected type feedback. They should
// soft deoptimize when there is no type feedback. // soft deoptimize when there is no type feedback.
...@@ -13256,7 +13242,7 @@ void HTracer::Trace(const char* name, HGraph* graph, LChunk* chunk) { ...@@ -13256,7 +13242,7 @@ void HTracer::Trace(const char* name, HGraph* graph, LChunk* chunk) {
if (FLAG_hydrogen_track_positions && if (FLAG_hydrogen_track_positions &&
instruction->has_position() && instruction->has_position() &&
instruction->position().raw() != 0) { instruction->position().raw() != 0) {
const HSourcePosition pos = instruction->position(); const SourcePosition pos = instruction->position();
os << " pos:"; os << " pos:";
if (pos.inlining_id() != 0) os << pos.inlining_id() << "_"; if (pos.inlining_id() != 0) os << pos.inlining_id() << "_";
os << pos.position(); os << pos.position();
......
...@@ -88,7 +88,7 @@ class HBasicBlock FINAL : public ZoneObject { ...@@ -88,7 +88,7 @@ class HBasicBlock FINAL : public ZoneObject {
bool IsFinished() const { return end_ != NULL; } bool IsFinished() const { return end_ != NULL; }
void AddPhi(HPhi* phi); void AddPhi(HPhi* phi);
void RemovePhi(HPhi* phi); void RemovePhi(HPhi* phi);
void AddInstruction(HInstruction* instr, HSourcePosition position); void AddInstruction(HInstruction* instr, SourcePosition position);
bool Dominates(HBasicBlock* other) const; bool Dominates(HBasicBlock* other) const;
bool EqualToOrDominates(HBasicBlock* other) const; bool EqualToOrDominates(HBasicBlock* other) const;
int LoopNestingDepth() const; int LoopNestingDepth() const;
...@@ -114,8 +114,7 @@ class HBasicBlock FINAL : public ZoneObject { ...@@ -114,8 +114,7 @@ class HBasicBlock FINAL : public ZoneObject {
int PredecessorIndexOf(HBasicBlock* predecessor) const; int PredecessorIndexOf(HBasicBlock* predecessor) const;
HPhi* AddNewPhi(int merged_index); HPhi* AddNewPhi(int merged_index);
HSimulate* AddNewSimulate(BailoutId ast_id, HSimulate* AddNewSimulate(BailoutId ast_id, SourcePosition position,
HSourcePosition position,
RemovableSimulate removable = FIXED_SIMULATE) { RemovableSimulate removable = FIXED_SIMULATE) {
HSimulate* instr = CreateSimulate(ast_id, removable); HSimulate* instr = CreateSimulate(ast_id, removable);
AddInstruction(instr, position); AddInstruction(instr, position);
...@@ -167,21 +166,18 @@ class HBasicBlock FINAL : public ZoneObject { ...@@ -167,21 +166,18 @@ class HBasicBlock FINAL : public ZoneObject {
friend class HGraphBuilder; friend class HGraphBuilder;
HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable); HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable);
void Finish(HControlInstruction* last, HSourcePosition position); void Finish(HControlInstruction* last, SourcePosition position);
void FinishExit(HControlInstruction* instruction, HSourcePosition position); void FinishExit(HControlInstruction* instruction, SourcePosition position);
void Goto(HBasicBlock* block, void Goto(HBasicBlock* block, SourcePosition position,
HSourcePosition position, FunctionState* state = NULL, bool add_simulate = true);
FunctionState* state = NULL, void GotoNoSimulate(HBasicBlock* block, SourcePosition position) {
bool add_simulate = true);
void GotoNoSimulate(HBasicBlock* block, HSourcePosition position) {
Goto(block, position, NULL, false); Goto(block, position, NULL, false);
} }
// Add the inlined function exit sequence, adding an HLeaveInlined // Add the inlined function exit sequence, adding an HLeaveInlined
// instruction and updating the bailout environment. // instruction and updating the bailout environment.
void AddLeaveInlined(HValue* return_value, void AddLeaveInlined(HValue* return_value, FunctionState* state,
FunctionState* state, SourcePosition position);
HSourcePosition position);
private: private:
void RegisterPredecessor(HBasicBlock* pred); void RegisterPredecessor(HBasicBlock* pred);
...@@ -461,11 +457,11 @@ class HGraph FINAL : public ZoneObject { ...@@ -461,11 +457,11 @@ class HGraph FINAL : public ZoneObject {
// identifier to each inlining and dumps function source if it was inlined // identifier to each inlining and dumps function source if it was inlined
// for the first time during the current optimization. // for the first time during the current optimization.
int TraceInlinedFunction(Handle<SharedFunctionInfo> shared, int TraceInlinedFunction(Handle<SharedFunctionInfo> shared,
HSourcePosition position); SourcePosition position);
// Converts given HSourcePosition to the absolute offset from the start of // Converts given SourcePosition to the absolute offset from the start of
// the corresponding script. // the corresponding script.
int SourcePositionToScriptPosition(HSourcePosition position); int SourcePositionToScriptPosition(SourcePosition position);
private: private:
HConstant* ReinsertConstantIfNecessary(HConstant* constant); HConstant* ReinsertConstantIfNecessary(HConstant* constant);
...@@ -941,7 +937,7 @@ class FunctionState FINAL { ...@@ -941,7 +937,7 @@ class FunctionState FINAL {
HArgumentsElements* arguments_elements_; HArgumentsElements* arguments_elements_;
int inlining_id_; int inlining_id_;
HSourcePosition outer_source_position_; SourcePosition outer_source_position_;
FunctionState* outer_; FunctionState* outer_;
}; };
...@@ -1029,7 +1025,7 @@ class HGraphBuilder { ...@@ -1029,7 +1025,7 @@ class HGraphBuilder {
graph_(NULL), graph_(NULL),
current_block_(NULL), current_block_(NULL),
scope_(info->scope()), scope_(info->scope()),
position_(HSourcePosition::Unknown()), position_(SourcePosition::Unknown()),
start_position_(0) {} start_position_(0) {}
virtual ~HGraphBuilder() {} virtual ~HGraphBuilder() {}
...@@ -1885,18 +1881,16 @@ class HGraphBuilder { ...@@ -1885,18 +1881,16 @@ class HGraphBuilder {
} }
// Convert the given absolute offset from the start of the script to // Convert the given absolute offset from the start of the script to
// the HSourcePosition assuming that this position corresponds to the // the SourcePosition assuming that this position corresponds to the
// same function as current position_. // same function as current position_.
HSourcePosition ScriptPositionToSourcePosition(int position) { SourcePosition ScriptPositionToSourcePosition(int position) {
HSourcePosition pos = position_; SourcePosition pos = position_;
pos.set_position(position - start_position_); pos.set_position(position - start_position_);
return pos; return pos;
} }
HSourcePosition source_position() { return position_; } SourcePosition source_position() { return position_; }
void set_source_position(HSourcePosition position) { void set_source_position(SourcePosition position) { position_ = position; }
position_ = position;
}
template <typename ViewClass> template <typename ViewClass>
void BuildArrayBufferViewInitialization(HValue* obj, void BuildArrayBufferViewInitialization(HValue* obj,
...@@ -1916,7 +1910,7 @@ class HGraphBuilder { ...@@ -1916,7 +1910,7 @@ class HGraphBuilder {
HGraph* graph_; HGraph* graph_;
HBasicBlock* current_block_; HBasicBlock* current_block_;
Scope* scope_; Scope* scope_;
HSourcePosition position_; SourcePosition position_;
int start_position_; int start_position_;
}; };
...@@ -2325,13 +2319,10 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor { ...@@ -2325,13 +2319,10 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {
Handle<JSFunction> target); Handle<JSFunction> target);
int InliningAstSize(Handle<JSFunction> target); int InliningAstSize(Handle<JSFunction> target);
bool TryInline(Handle<JSFunction> target, bool TryInline(Handle<JSFunction> target, int arguments_count,
int arguments_count, HValue* implicit_return_value, BailoutId ast_id,
HValue* implicit_return_value, BailoutId return_id, InliningKind inlining_kind,
BailoutId ast_id, SourcePosition position);
BailoutId return_id,
InliningKind inlining_kind,
HSourcePosition position);
bool TryInlineCall(Call* expr); bool TryInlineCall(Call* expr);
bool TryInlineConstruct(CallNew* expr, HValue* implicit_return_value); bool TryInlineConstruct(CallNew* expr, HValue* implicit_return_value);
...@@ -2597,15 +2588,9 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor { ...@@ -2597,15 +2588,9 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {
}; };
HControlInstruction* BuildCompareInstruction( HControlInstruction* BuildCompareInstruction(
Token::Value op, Token::Value op, HValue* left, HValue* right, Type* left_type,
HValue* left, Type* right_type, Type* combined_type, SourcePosition left_position,
HValue* right, SourcePosition right_position, PushBeforeSimulateBehavior push_sim_result,
Type* left_type,
Type* right_type,
Type* combined_type,
HSourcePosition left_position,
HSourcePosition right_position,
PushBeforeSimulateBehavior push_sim_result,
BailoutId bailout_id); BailoutId bailout_id);
HInstruction* BuildStringCharCodeAt(HValue* string, HInstruction* BuildStringCharCodeAt(HValue* string,
......
...@@ -1906,6 +1906,9 @@ Isolate::~Isolate() { ...@@ -1906,6 +1906,9 @@ Isolate::~Isolate() {
delete handle_scope_implementer_; delete handle_scope_implementer_;
handle_scope_implementer_ = NULL; handle_scope_implementer_ = NULL;
delete code_tracer();
set_code_tracer(NULL);
delete compilation_cache_; delete compilation_cache_;
compilation_cache_ = NULL; compilation_cache_ = NULL;
delete bootstrapper_; delete bootstrapper_;
......
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