Move RelocInfo::kNoPosition.

R=mstarzinger@chromium.org
BUG=v8:5117

Review-Url: https://codereview.chromium.org/2109773004
Cr-Commit-Position: refs/heads/master@{#37426}
This commit is contained in:
yangguo 2016-06-30 02:26:30 -07:00 committed by Commit bot
parent 38b31043ec
commit 141cddc720
32 changed files with 374 additions and 356 deletions

1
buffer Normal file
View File

@ -0,0 +1 @@
27,27,27,27,27,66,66,66,66,105,105,216,216,216,216,280,280,280,293,293,293,301,301,301,317

48
patch Normal file
View File

@ -0,0 +1,48 @@
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 5624e3f..81936c1 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -17049,6 +17049,43 @@ TEST(CaptureStackTraceForUncaughtExceptionAndSetters) {
}
+static void StackTraceFunctionNameListenerForEval(v8::Local<v8::Message> message,
+ v8::Local<Value>) {
+ v8::Local<v8::StackTrace> stack_trace = message->GetStackTrace();
+ for (int i = 0; i < stack_trace->GetFrameCount(); i++) {
+ v8::Local<v8::StackFrame> frame = stack_trace->GetFrame(i);
+ v8::String::Utf8Value func_name(frame->GetFunctionName());
+ v8::String::Utf8Value script_name(frame->GetScriptName());
+ printf("%s:%s, %d,%d\n", *script_name, *func_name, frame->GetLineNumber(), frame->GetColumn());
+ }
+
+
+ CHECK_EQ(5, stack_trace->GetFrameCount());
+ checkStackFrame("origin", "foo:0", 4, 7, false, false,
+ stack_trace->GetFrame(0));
+ checkStackFrame("origin", "foo:1", 5, 27, false, false,
+ stack_trace->GetFrame(1));
+ checkStackFrame("origin", "foo", 5, 27, false, false,
+ stack_trace->GetFrame(2));
+ checkStackFrame("origin", "foo", 5, 27, false, false,
+ stack_trace->GetFrame(3));
+ checkStackFrame("origin", "", 1, 14, false, false, stack_trace->GetFrame(4));
+}
+
+
+TEST(CaptureStackTraceForUncaughtExceptionInEval) {
+ LocalContext env;
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
+ isolate->SetCaptureStackTraceForUncaughtExceptions(true, 1024,
+ v8::StackTrace::kDetailed);
+ isolate->AddMessageListener(StackTraceFunctionNameListenerForEval);
+
+ CompileRun("eval('throw new Error()');");
+ isolate->SetCaptureStackTraceForUncaughtExceptions(false);
+}
+
+
static void StackTraceFunctionNameListener(v8::Local<v8::Message> message,
v8::Local<Value>) {
v8::Local<v8::StackTrace> stack_trace = message->GetStackTrace();

View File

@ -38,6 +38,7 @@
#include "src/execution.h" #include "src/execution.h"
#include "src/gdb-jit.h" #include "src/gdb-jit.h"
#include "src/global-handles.h" #include "src/global-handles.h"
#include "src/globals.h"
#include "src/icu_util.h" #include "src/icu_util.h"
#include "src/isolate-inl.h" #include "src/isolate-inl.h"
#include "src/json-parser.h" #include "src/json-parser.h"
@ -2112,7 +2113,7 @@ MaybeLocal<Function> ScriptCompiler::CompileFunctionInContext(
i::Handle<i::Object> name_obj; i::Handle<i::Object> name_obj;
int eval_scope_position = 0; int eval_scope_position = 0;
int eval_position = i::RelocInfo::kNoPosition; int eval_position = i::kNoSourcePosition;
int line_offset = 0; int line_offset = 0;
int column_offset = 0; int column_offset = 0;
if (!source->resource_name.IsEmpty()) { if (!source->resource_name.IsEmpty()) {

View File

@ -352,17 +352,6 @@ enum ICacheFlushMode { FLUSH_ICACHE_IF_NEEDED, SKIP_ICACHE_FLUSH };
class RelocInfo { class RelocInfo {
public: public:
// The constant kNoPosition is used with the collecting of source positions
// in the relocation information. Two types of source positions are collected
// "position" (RelocMode position) and "statement position" (RelocMode
// statement_position). The "position" is collected at places in the source
// code which are of interest when making stack traces to pin-point the source
// location of a stack frame as close as possible. The "statement position" is
// collected at the beginning at each statement, and is used to indicate
// possible break locations. kNoPosition is used to indicate an
// invalid/uninitialized position value.
static const int kNoPosition = -1;
// This string is used to add padding comments to the reloc info in cases // This string is used to add padding comments to the reloc info in cases
// where we are not sure to have enough space for patching in during // where we are not sure to have enough space for patching in during
// lazy deoptimization. This is the case if we have indirect calls for which // lazy deoptimization. This is the case if we have indirect calls for which

View File

@ -5,7 +5,6 @@
#ifndef V8_AST_AST_H_ #ifndef V8_AST_AST_H_
#define V8_AST_AST_H_ #define V8_AST_AST_H_
#include "src/assembler.h"
#include "src/ast/ast-value-factory.h" #include "src/ast/ast-value-factory.h"
#include "src/ast/modules.h" #include "src/ast/modules.h"
#include "src/ast/variables.h" #include "src/ast/variables.h"
@ -13,6 +12,7 @@
#include "src/base/flags.h" #include "src/base/flags.h"
#include "src/base/smart-pointers.h" #include "src/base/smart-pointers.h"
#include "src/factory.h" #include "src/factory.h"
#include "src/globals.h"
#include "src/isolate.h" #include "src/isolate.h"
#include "src/list.h" #include "src/list.h"
#include "src/parsing/token.h" #include "src/parsing/token.h"
@ -1263,7 +1263,7 @@ class SloppyBlockFunctionStatement final : public Statement {
private: private:
SloppyBlockFunctionStatement(Zone* zone, Statement* statement, Scope* scope) SloppyBlockFunctionStatement(Zone* zone, Statement* statement, Scope* scope)
: Statement(zone, RelocInfo::kNoPosition), : Statement(zone, kNoSourcePosition),
statement_(statement), statement_(statement),
scope_(scope) {} scope_(scope) {}
@ -2704,7 +2704,7 @@ class FunctionLiteral final : public Expression {
materialized_literal_count_(materialized_literal_count), materialized_literal_count_(materialized_literal_count),
expected_property_count_(expected_property_count), expected_property_count_(expected_property_count),
parameter_count_(parameter_count), parameter_count_(parameter_count),
function_token_position_(RelocInfo::kNoPosition), function_token_position_(kNoSourcePosition),
yield_count_(0) { yield_count_(0) {
bitfield_ = bitfield_ =
FunctionTypeBits::encode(function_type) | Pretenure::encode(false) | FunctionTypeBits::encode(function_type) | Pretenure::encode(false) |
@ -3292,16 +3292,16 @@ class AstNodeFactory final BASE_EMBEDDED {
} }
VariableProxy* NewVariableProxy(Variable* var, VariableProxy* NewVariableProxy(Variable* var,
int start_position = RelocInfo::kNoPosition, int start_position = kNoSourcePosition,
int end_position = RelocInfo::kNoPosition) { int end_position = kNoSourcePosition) {
return new (parser_zone_) return new (parser_zone_)
VariableProxy(parser_zone_, var, start_position, end_position); VariableProxy(parser_zone_, var, start_position, end_position);
} }
VariableProxy* NewVariableProxy(const AstRawString* name, VariableProxy* NewVariableProxy(const AstRawString* name,
Variable::Kind variable_kind, Variable::Kind variable_kind,
int start_position = RelocInfo::kNoPosition, int start_position = kNoSourcePosition,
int end_position = RelocInfo::kNoPosition) { int end_position = kNoSourcePosition) {
DCHECK_NOT_NULL(name); DCHECK_NOT_NULL(name);
return new (parser_zone_) VariableProxy(parser_zone_, name, variable_kind, return new (parser_zone_) VariableProxy(parser_zone_, name, variable_kind,
start_position, end_position); start_position, end_position);

View File

@ -194,8 +194,8 @@ void Scope::SetDefaults(ScopeType scope_type, Scope* outer_scope,
rest_parameter_ = NULL; rest_parameter_ = NULL;
rest_index_ = -1; rest_index_ = -1;
scope_info_ = scope_info; scope_info_ = scope_info;
start_position_ = RelocInfo::kNoPosition; start_position_ = kNoSourcePosition;
end_position_ = RelocInfo::kNoPosition; end_position_ = kNoSourcePosition;
is_hidden_ = false; is_hidden_ = false;
if (!scope_info.is_null()) { if (!scope_info.is_null()) {
scope_calls_eval_ = scope_info->CallsEval(); scope_calls_eval_ = scope_info->CallsEval();
@ -455,8 +455,8 @@ Variable* Scope::LookupFunctionVar(const AstRawString* name,
Variable* var = new (zone()) Variable* var = new (zone())
Variable(this, name, mode, Variable::NORMAL, kCreatedInitialized); Variable(this, name, mode, Variable::NORMAL, kCreatedInitialized);
VariableProxy* proxy = factory->NewVariableProxy(var); VariableProxy* proxy = factory->NewVariableProxy(var);
VariableDeclaration* declaration = factory->NewVariableDeclaration( VariableDeclaration* declaration =
proxy, mode, this, RelocInfo::kNoPosition); factory->NewVariableDeclaration(proxy, mode, this, kNoSourcePosition);
DeclareFunctionVar(declaration); DeclareFunctionVar(declaration);
var->AllocateTo(VariableLocation::CONTEXT, index); var->AllocateTo(VariableLocation::CONTEXT, index);
return var; return var;
@ -1016,8 +1016,8 @@ void Scope::CheckScopePositions() {
// A scope is allowed to have invalid positions if it is hidden and has no // A scope is allowed to have invalid positions if it is hidden and has no
// inner scopes // inner scopes
if (!is_hidden() && inner_scopes_.length() == 0) { if (!is_hidden() && inner_scopes_.length() == 0) {
CHECK_NE(RelocInfo::kNoPosition, start_position()); CHECK_NE(kNoSourcePosition, start_position());
CHECK_NE(RelocInfo::kNoPosition, end_position()); CHECK_NE(kNoSourcePosition, end_position());
} }
for (Scope* scope : inner_scopes_) scope->CheckScopePositions(); for (Scope* scope : inner_scopes_) scope->CheckScopePositions();
} }

View File

@ -7,6 +7,7 @@
#include "src/ast/ast.h" #include "src/ast/ast.h"
#include "src/base/hashmap.h" #include "src/base/hashmap.h"
#include "src/globals.h"
#include "src/pending-compilation-error-handler.h" #include "src/pending-compilation-error-handler.h"
#include "src/zone.h" #include "src/zone.h"
@ -174,8 +175,8 @@ class Scope: public ZoneObject {
VariableProxy* NewUnresolved(AstNodeFactory* factory, VariableProxy* NewUnresolved(AstNodeFactory* factory,
const AstRawString* name, const AstRawString* name,
Variable::Kind kind = Variable::NORMAL, Variable::Kind kind = Variable::NORMAL,
int start_position = RelocInfo::kNoPosition, int start_position = kNoSourcePosition,
int end_position = RelocInfo::kNoPosition) { int end_position = kNoSourcePosition) {
// Note that we must not share the unresolved variables with // Note that we must not share the unresolved variables with
// the same name because they may be removed selectively via // the same name because they may be removed selectively via
// RemoveUnresolved(). // RemoveUnresolved().

View File

@ -6,6 +6,7 @@
#include "src/ast/ast.h" #include "src/ast/ast.h"
#include "src/ast/scopes.h" #include "src/ast/scopes.h"
#include "src/globals.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
@ -28,7 +29,6 @@ const char* Variable::Mode2String(VariableMode mode) {
return NULL; return NULL;
} }
Variable::Variable(Scope* scope, const AstRawString* name, VariableMode mode, Variable::Variable(Scope* scope, const AstRawString* name, VariableMode mode,
Kind kind, InitializationFlag initialization_flag, Kind kind, InitializationFlag initialization_flag,
MaybeAssignedFlag maybe_assigned_flag) MaybeAssignedFlag maybe_assigned_flag)
@ -38,7 +38,7 @@ Variable::Variable(Scope* scope, const AstRawString* name, VariableMode mode,
kind_(kind), kind_(kind),
location_(VariableLocation::UNALLOCATED), location_(VariableLocation::UNALLOCATED),
index_(-1), index_(-1),
initializer_position_(RelocInfo::kNoPosition), initializer_position_(kNoSourcePosition),
local_if_not_shadowed_(NULL), local_if_not_shadowed_(NULL),
force_context_allocation_(false), force_context_allocation_(false),
is_used_(false), is_used_(false),

View File

@ -16,6 +16,7 @@
#include "src/elements.h" #include "src/elements.h"
#include "src/frames-inl.h" #include "src/frames-inl.h"
#include "src/gdb-jit.h" #include "src/gdb-jit.h"
#include "src/globals.h"
#include "src/ic/handler-compiler.h" #include "src/ic/handler-compiler.h"
#include "src/ic/ic.h" #include "src/ic/ic.h"
#include "src/isolate-inl.h" #include "src/isolate-inl.h"
@ -2183,7 +2184,7 @@ MaybeHandle<JSFunction> CompileString(Handle<Context> context,
// Compile source string in the native context. // Compile source string in the native context.
int eval_scope_position = 0; int eval_scope_position = 0;
int eval_position = RelocInfo::kNoPosition; int eval_position = kNoSourcePosition;
Handle<SharedFunctionInfo> outer_info(native_context->closure()->shared()); Handle<SharedFunctionInfo> outer_info(native_context->closure()->shared());
return Compiler::GetFunctionFromEval(source, outer_info, native_context, return Compiler::GetFunctionFromEval(source, outer_info, native_context,
SLOPPY, restriction, eval_scope_position, SLOPPY, restriction, eval_scope_position,

View File

@ -4,9 +4,9 @@
#include "src/compilation-cache.h" #include "src/compilation-cache.h"
#include "src/assembler.h"
#include "src/counters.h" #include "src/counters.h"
#include "src/factory.h" #include "src/factory.h"
#include "src/globals.h"
#include "src/objects-inl.h" #include "src/objects-inl.h"
namespace v8 { namespace v8 {
@ -308,7 +308,7 @@ MaybeHandle<SharedFunctionInfo> CompilationCache::LookupEval(
result = result =
eval_global_.Lookup(source, outer_info, language_mode, scope_position); eval_global_.Lookup(source, outer_info, language_mode, scope_position);
} else { } else {
DCHECK(scope_position != RelocInfo::kNoPosition); DCHECK(scope_position != kNoSourcePosition);
result = eval_contextual_.Lookup(source, outer_info, language_mode, result = eval_contextual_.Lookup(source, outer_info, language_mode,
scope_position); scope_position);
} }
@ -345,7 +345,7 @@ void CompilationCache::PutEval(Handle<String> source,
if (context->IsNativeContext()) { if (context->IsNativeContext()) {
eval_global_.Put(source, outer_info, function_info, scope_position); eval_global_.Put(source, outer_info, function_info, scope_position);
} else { } else {
DCHECK(scope_position != RelocInfo::kNoPosition); DCHECK(scope_position != kNoSourcePosition);
eval_contextual_.Put(source, outer_info, function_info, scope_position); eval_contextual_.Put(source, outer_info, function_info, scope_position);
} }
} }

View File

@ -20,6 +20,7 @@
#include "src/deoptimizer.h" #include "src/deoptimizer.h"
#include "src/frames-inl.h" #include "src/frames-inl.h"
#include "src/full-codegen/full-codegen.h" #include "src/full-codegen/full-codegen.h"
#include "src/globals.h"
#include "src/interpreter/interpreter.h" #include "src/interpreter/interpreter.h"
#include "src/isolate-inl.h" #include "src/isolate-inl.h"
#include "src/log-inl.h" #include "src/log-inl.h"
@ -1099,7 +1100,7 @@ Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
TRACE_EVENT0("v8", parse_info->is_eval() ? "V8.CompileEval" : "V8.Compile"); TRACE_EVENT0("v8", parse_info->is_eval() ? "V8.CompileEval" : "V8.Compile");
// Allocate a shared function info object. // Allocate a shared function info object.
DCHECK_EQ(RelocInfo::kNoPosition, lit->function_token_position()); DCHECK_EQ(kNoSourcePosition, lit->function_token_position());
result = NewSharedFunctionInfoForLiteral(isolate, lit, script); result = NewSharedFunctionInfoForLiteral(isolate, lit, script);
result->set_is_toplevel(true); result->set_is_toplevel(true);
if (parse_info->is_eval()) { if (parse_info->is_eval()) {

View File

@ -5,8 +5,8 @@
#ifndef V8_COMPILER_SOURCE_POSITION_H_ #ifndef V8_COMPILER_SOURCE_POSITION_H_
#define V8_COMPILER_SOURCE_POSITION_H_ #define V8_COMPILER_SOURCE_POSITION_H_
#include "src/assembler.h"
#include "src/compiler/node-aux-data.h" #include "src/compiler/node-aux-data.h"
#include "src/globals.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
@ -25,7 +25,7 @@ class SourcePosition final {
int raw() const { return raw_; } int raw() const { return raw_; }
private: private:
static const int kUnknownPosition = RelocInfo::kNoPosition; static const int kUnknownPosition = kNoSourcePosition;
int raw_; int raw_;
}; };

View File

@ -16,6 +16,7 @@
#include "src/crankshaft/hydrogen-types.h" #include "src/crankshaft/hydrogen-types.h"
#include "src/crankshaft/unique.h" #include "src/crankshaft/unique.h"
#include "src/deoptimizer.h" #include "src/deoptimizer.h"
#include "src/globals.h"
#include "src/small-pointer-list.h" #include "src/small-pointer-list.h"
#include "src/utils.h" #include "src/utils.h"
#include "src/zone.h" #include "src/zone.h"
@ -1113,7 +1114,7 @@ class HInstruction : public HValue {
: HValue(type), : HValue(type),
next_(NULL), next_(NULL),
previous_(NULL), previous_(NULL),
position_(RelocInfo::kNoPosition) { position_(kNoSourcePosition) {
SetDependsOnFlag(kOsrEntries); SetDependsOnFlag(kOsrEntries);
} }

View File

@ -35,6 +35,7 @@
#include "src/crankshaft/typing.h" #include "src/crankshaft/typing.h"
#include "src/field-type.h" #include "src/field-type.h"
#include "src/full-codegen/full-codegen.h" #include "src/full-codegen/full-codegen.h"
#include "src/globals.h"
#include "src/ic/call-optimization.h" #include "src/ic/call-optimization.h"
#include "src/ic/ic.h" #include "src/ic/ic.h"
// GetRootConstructor // GetRootConstructor
@ -78,7 +79,7 @@ class HOptimizedGraphBuilderWithPositions : public HOptimizedGraphBuilder {
#define DEF_VISIT(type) \ #define DEF_VISIT(type) \
void Visit##type(type* node) override { \ void Visit##type(type* node) override { \
SourcePosition old_position = SourcePosition::Unknown(); \ SourcePosition old_position = SourcePosition::Unknown(); \
if (node->position() != RelocInfo::kNoPosition) { \ if (node->position() != kNoSourcePosition) { \
old_position = source_position(); \ old_position = source_position(); \
SetSourcePosition(node->position()); \ SetSourcePosition(node->position()); \
} \ } \
@ -93,7 +94,7 @@ class HOptimizedGraphBuilderWithPositions : public HOptimizedGraphBuilder {
#define DEF_VISIT(type) \ #define DEF_VISIT(type) \
void Visit##type(type* node) override { \ void Visit##type(type* node) override { \
SourcePosition old_position = SourcePosition::Unknown(); \ SourcePosition old_position = SourcePosition::Unknown(); \
if (node->position() != RelocInfo::kNoPosition) { \ if (node->position() != kNoSourcePosition) { \
old_position = source_position(); \ old_position = source_position(); \
SetSourcePosition(node->position()); \ SetSourcePosition(node->position()); \
} \ } \

View File

@ -14,6 +14,7 @@
#include "src/compiler.h" #include "src/compiler.h"
#include "src/crankshaft/compilation-phase.h" #include "src/crankshaft/compilation-phase.h"
#include "src/crankshaft/hydrogen-instructions.h" #include "src/crankshaft/hydrogen-instructions.h"
#include "src/globals.h"
#include "src/parsing/parser.h" #include "src/parsing/parser.h"
#include "src/zone.h" #include "src/zone.h"
@ -1923,7 +1924,7 @@ class HGraphBuilder {
protected: protected:
void SetSourcePosition(int position) { void SetSourcePosition(int position) {
if (position != RelocInfo::kNoPosition) { if (position != kNoSourcePosition) {
position_.set_position(position - start_position_); position_.set_position(position - start_position_);
} }
// Otherwise position remains unknown. // Otherwise position remains unknown.
@ -1940,7 +1941,7 @@ class HGraphBuilder {
// the SourcePosition 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_.
SourcePosition ScriptPositionToSourcePosition(int position) { SourcePosition ScriptPositionToSourcePosition(int position) {
if (position == RelocInfo::kNoPosition) { if (position == kNoSourcePosition) {
return SourcePosition::Unknown(); return SourcePosition::Unknown();
} }
SourcePosition pos = position_; SourcePosition pos = position_;

View File

@ -37,6 +37,8 @@
#error Unsupported target architecture. #error Unsupported target architecture.
#endif #endif
#include "src/globals.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
@ -137,7 +139,7 @@ void LCodeGenBase::CheckEnvironmentUsage() {
} }
void LCodeGenBase::RecordAndWritePosition(int pos) { void LCodeGenBase::RecordAndWritePosition(int pos) {
if (pos == RelocInfo::kNoPosition) return; if (pos == kNoSourcePosition) return;
source_position_table_builder_.AddPosition(masm_->pc_offset(), pos, false); source_position_table_builder_.AddPosition(masm_->pc_offset(), pos, false);
} }

View File

@ -6,10 +6,11 @@
#include "src/accessors.h" #include "src/accessors.h"
#include "src/contexts.h" #include "src/contexts.h"
#include "src/debug/debug.h"
#include "src/debug/debug-frames.h" #include "src/debug/debug-frames.h"
#include "src/debug/debug-scopes.h" #include "src/debug/debug-scopes.h"
#include "src/debug/debug.h"
#include "src/frames-inl.h" #include "src/frames-inl.h"
#include "src/globals.h"
#include "src/isolate-inl.h" #include "src/isolate-inl.h"
namespace v8 { namespace v8 {
@ -98,9 +99,9 @@ MaybeHandle<Object> DebugEvaluate::Evaluate(
Handle<JSFunction> eval_fun; Handle<JSFunction> eval_fun;
ASSIGN_RETURN_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate, eval_fun, isolate, eval_fun,
Compiler::GetFunctionFromEval( Compiler::GetFunctionFromEval(source, outer_info, context, SLOPPY,
source, outer_info, context, SLOPPY, NO_PARSE_RESTRICTION, NO_PARSE_RESTRICTION, kNoSourcePosition,
RelocInfo::kNoPosition, RelocInfo::kNoPosition), kNoSourcePosition),
Object); Object);
Handle<Object> result; Handle<Object> result;

View File

@ -16,6 +16,7 @@
#include "src/frames-inl.h" #include "src/frames-inl.h"
#include "src/full-codegen/full-codegen.h" #include "src/full-codegen/full-codegen.h"
#include "src/global-handles.h" #include "src/global-handles.h"
#include "src/globals.h"
#include "src/interpreter/interpreter.h" #include "src/interpreter/interpreter.h"
#include "src/isolate-inl.h" #include "src/isolate-inl.h"
#include "src/list.h" #include "src/list.h"
@ -466,7 +467,7 @@ void Debug::ThreadInit() {
thread_local_.break_id_ = 0; thread_local_.break_id_ = 0;
thread_local_.break_frame_id_ = StackFrame::NO_ID; thread_local_.break_frame_id_ = StackFrame::NO_ID;
thread_local_.last_step_action_ = StepNone; thread_local_.last_step_action_ = StepNone;
thread_local_.last_statement_position_ = RelocInfo::kNoPosition; thread_local_.last_statement_position_ = kNoSourcePosition;
thread_local_.last_fp_ = 0; thread_local_.last_fp_ = 0;
thread_local_.target_fp_ = 0; thread_local_.target_fp_ = 0;
thread_local_.return_value_ = Handle<Object>(); thread_local_.return_value_ = Handle<Object>();
@ -1070,7 +1071,7 @@ void Debug::PrepareStep(StepAction step_action) {
thread_local_.target_fp_ = frames_it.frame()->UnpaddedFP(); thread_local_.target_fp_ = frames_it.frame()->UnpaddedFP();
} }
// Clear last position info. For stepping out it does not matter. // Clear last position info. For stepping out it does not matter.
thread_local_.last_statement_position_ = RelocInfo::kNoPosition; thread_local_.last_statement_position_ = kNoSourcePosition;
thread_local_.last_fp_ = 0; thread_local_.last_fp_ = 0;
break; break;
case StepNext: case StepNext:
@ -1131,7 +1132,7 @@ void Debug::ClearStepping() {
ClearOneShot(); ClearOneShot();
thread_local_.last_step_action_ = StepNone; thread_local_.last_step_action_ = StepNone;
thread_local_.last_statement_position_ = RelocInfo::kNoPosition; thread_local_.last_statement_position_ = kNoSourcePosition;
thread_local_.last_fp_ = 0; thread_local_.last_fp_ = 0;
thread_local_.target_fp_ = 0; thread_local_.target_fp_ = 0;
} }
@ -1393,13 +1394,13 @@ class SharedFunctionInfoFinder {
explicit SharedFunctionInfoFinder(int target_position) explicit SharedFunctionInfoFinder(int target_position)
: current_candidate_(NULL), : current_candidate_(NULL),
current_candidate_closure_(NULL), current_candidate_closure_(NULL),
current_start_position_(RelocInfo::kNoPosition), current_start_position_(kNoSourcePosition),
target_position_(target_position) {} target_position_(target_position) {}
void NewCandidate(SharedFunctionInfo* shared, JSFunction* closure = NULL) { void NewCandidate(SharedFunctionInfo* shared, JSFunction* closure = NULL) {
if (!shared->IsSubjectToDebugging()) return; if (!shared->IsSubjectToDebugging()) return;
int start_position = shared->function_token_position(); int start_position = shared->function_token_position();
if (start_position == RelocInfo::kNoPosition) { if (start_position == kNoSourcePosition) {
start_position = shared->start_position(); start_position = shared->start_position();
} }

View File

@ -15,6 +15,7 @@
#include "src/debug/debug.h" #include "src/debug/debug.h"
#include "src/debug/liveedit.h" #include "src/debug/liveedit.h"
#include "src/frames-inl.h" #include "src/frames-inl.h"
#include "src/globals.h"
#include "src/isolate-inl.h" #include "src/isolate-inl.h"
#include "src/macro-assembler.h" #include "src/macro-assembler.h"
#include "src/snapshot/snapshot.h" #include "src/snapshot/snapshot.h"
@ -600,12 +601,12 @@ void FullCodeGenerator::EmitHasProperty() {
} }
void FullCodeGenerator::RecordStatementPosition(int pos) { void FullCodeGenerator::RecordStatementPosition(int pos) {
DCHECK_NE(RelocInfo::kNoPosition, pos); DCHECK_NE(kNoSourcePosition, pos);
source_position_table_builder_.AddPosition(masm_->pc_offset(), pos, true); source_position_table_builder_.AddPosition(masm_->pc_offset(), pos, true);
} }
void FullCodeGenerator::RecordPosition(int pos) { void FullCodeGenerator::RecordPosition(int pos) {
DCHECK_NE(RelocInfo::kNoPosition, pos); DCHECK_NE(kNoSourcePosition, pos);
source_position_table_builder_.AddPosition(masm_->pc_offset(), pos, false); source_position_table_builder_.AddPosition(masm_->pc_offset(), pos, false);
} }
@ -629,7 +630,7 @@ void FullCodeGenerator::SetReturnPosition(FunctionLiteral* fun) {
void FullCodeGenerator::SetStatementPosition( void FullCodeGenerator::SetStatementPosition(
Statement* stmt, FullCodeGenerator::InsertBreak insert_break) { Statement* stmt, FullCodeGenerator::InsertBreak insert_break) {
if (stmt->position() == RelocInfo::kNoPosition) return; if (stmt->position() == kNoSourcePosition) return;
RecordStatementPosition(stmt->position()); RecordStatementPosition(stmt->position());
if (insert_break == INSERT_BREAK && info_->is_debug() && if (insert_break == INSERT_BREAK && info_->is_debug() &&
!stmt->IsDebuggerStatement()) { !stmt->IsDebuggerStatement()) {
@ -638,13 +639,13 @@ void FullCodeGenerator::SetStatementPosition(
} }
void FullCodeGenerator::SetExpressionPosition(Expression* expr) { void FullCodeGenerator::SetExpressionPosition(Expression* expr) {
if (expr->position() == RelocInfo::kNoPosition) return; if (expr->position() == kNoSourcePosition) return;
RecordPosition(expr->position()); RecordPosition(expr->position());
} }
void FullCodeGenerator::SetExpressionAsStatementPosition(Expression* expr) { void FullCodeGenerator::SetExpressionAsStatementPosition(Expression* expr) {
if (expr->position() == RelocInfo::kNoPosition) return; if (expr->position() == kNoSourcePosition) return;
RecordStatementPosition(expr->position()); RecordStatementPosition(expr->position());
if (info_->is_debug()) { if (info_->is_debug()) {
DebugCodegen::GenerateSlot(masm_, RelocInfo::DEBUG_BREAK_SLOT_AT_POSITION); DebugCodegen::GenerateSlot(masm_, RelocInfo::DEBUG_BREAK_SLOT_AT_POSITION);
@ -653,7 +654,7 @@ void FullCodeGenerator::SetExpressionAsStatementPosition(Expression* expr) {
void FullCodeGenerator::SetCallPosition(Expression* expr, void FullCodeGenerator::SetCallPosition(Expression* expr,
TailCallMode tail_call_mode) { TailCallMode tail_call_mode) {
if (expr->position() == RelocInfo::kNoPosition) return; if (expr->position() == kNoSourcePosition) return;
RecordPosition(expr->position()); RecordPosition(expr->position());
if (info_->is_debug()) { if (info_->is_debug()) {
RelocInfo::Mode mode = (tail_call_mode == TailCallMode::kAllow) RelocInfo::Mode mode = (tail_call_mode == TailCallMode::kAllow)
@ -1964,8 +1965,8 @@ bool FullCodeGenerator::NeedsHoleCheckForLoad(VariableProxy* proxy) {
} }
// Check that we always have valid source position. // Check that we always have valid source position.
DCHECK(var->initializer_position() != RelocInfo::kNoPosition); DCHECK(var->initializer_position() != kNoSourcePosition);
DCHECK(proxy->position() != RelocInfo::kNoPosition); DCHECK(proxy->position() != kNoSourcePosition);
return var->scope()->is_nonlinear() || return var->scope()->is_nonlinear() ||
var->initializer_position() >= proxy->position(); var->initializer_position() >= proxy->position();

View File

@ -293,6 +293,8 @@ inline LanguageMode construct_language_mode(bool strict_bit) {
return static_cast<LanguageMode>(strict_bit); return static_cast<LanguageMode>(strict_bit);
} }
// This constant is used as an undefined value when passing source positions.
const int kNoSourcePosition = -1;
// Mask for the sign bit in a smi. // Mask for the sign bit in a smi.
const intptr_t kSmiSignMask = kIntptrSignBit; const intptr_t kSmiSignMask = kIntptrSignBit;

View File

@ -5,6 +5,7 @@
#include "src/interpreter/bytecode-array-builder.h" #include "src/interpreter/bytecode-array-builder.h"
#include "src/compiler.h" #include "src/compiler.h"
#include "src/globals.h"
#include "src/interpreter/bytecode-array-writer.h" #include "src/interpreter/bytecode-array-writer.h"
#include "src/interpreter/bytecode-dead-code-optimizer.h" #include "src/interpreter/bytecode-dead-code-optimizer.h"
#include "src/interpreter/bytecode-label.h" #include "src/interpreter/bytecode-label.h"
@ -52,7 +53,7 @@ BytecodeArrayBuilder::BytecodeArrayBuilder(Isolate* isolate, Zone* zone,
return_position_ = return_position_ =
literal ? std::max(literal->start_position(), literal->end_position() - 1) literal ? std::max(literal->start_position(), literal->end_position() - 1)
: RelocInfo::kNoPosition; : kNoSourcePosition;
} }
Register BytecodeArrayBuilder::first_context_register() const { Register BytecodeArrayBuilder::first_context_register() const {
@ -443,7 +444,7 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfNotHole(
} }
BytecodeArrayBuilder& BytecodeArrayBuilder::StackCheck(int position) { BytecodeArrayBuilder& BytecodeArrayBuilder::StackCheck(int position) {
if (position != RelocInfo::kNoPosition) { if (position != kNoSourcePosition) {
// We need to attach a non-breakable source position to a stack // We need to attach a non-breakable source position to a stack
// check, so we simply add it as expression position. There can be // check, so we simply add it as expression position. There can be
// a prior statement position from constructs like: // a prior statement position from constructs like:
@ -631,17 +632,17 @@ size_t BytecodeArrayBuilder::GetConstantPoolEntry(Handle<Object> object) {
} }
void BytecodeArrayBuilder::SetReturnPosition() { void BytecodeArrayBuilder::SetReturnPosition() {
if (return_position_ == RelocInfo::kNoPosition) return; if (return_position_ == kNoSourcePosition) return;
latest_source_info_.MakeStatementPosition(return_position_); latest_source_info_.MakeStatementPosition(return_position_);
} }
void BytecodeArrayBuilder::SetStatementPosition(Statement* stmt) { void BytecodeArrayBuilder::SetStatementPosition(Statement* stmt) {
if (stmt->position() == RelocInfo::kNoPosition) return; if (stmt->position() == kNoSourcePosition) return;
latest_source_info_.MakeStatementPosition(stmt->position()); latest_source_info_.MakeStatementPosition(stmt->position());
} }
void BytecodeArrayBuilder::SetExpressionPosition(Expression* expr) { void BytecodeArrayBuilder::SetExpressionPosition(Expression* expr) {
if (expr->position() == RelocInfo::kNoPosition) return; if (expr->position() == kNoSourcePosition) return;
if (!latest_source_info_.is_statement()) { if (!latest_source_info_.is_statement()) {
// Ensure the current expression position is overwritten with the // Ensure the current expression position is overwritten with the
// latest value. // latest value.
@ -650,7 +651,7 @@ void BytecodeArrayBuilder::SetExpressionPosition(Expression* expr) {
} }
void BytecodeArrayBuilder::SetExpressionAsStatementPosition(Expression* expr) { void BytecodeArrayBuilder::SetExpressionAsStatementPosition(Expression* expr) {
if (expr->position() == RelocInfo::kNoPosition) return; if (expr->position() == kNoSourcePosition) return;
latest_source_info_.MakeStatementPosition(expr->position()); latest_source_info_.MakeStatementPosition(expr->position());
} }

View File

@ -34,6 +34,7 @@
#include "src/field-type.h" #include "src/field-type.h"
#include "src/frames-inl.h" #include "src/frames-inl.h"
#include "src/full-codegen/full-codegen.h" #include "src/full-codegen/full-codegen.h"
#include "src/globals.h"
#include "src/ic/ic.h" #include "src/ic/ic.h"
#include "src/identity-map.h" #include "src/identity-map.h"
#include "src/interpreter/bytecode-array-iterator.h" #include "src/interpreter/bytecode-array-iterator.h"
@ -12706,7 +12707,7 @@ void Oddball::Initialize(Isolate* isolate, Handle<Oddball> oddball,
void Script::SetEvalOrigin(Handle<Script> script, void Script::SetEvalOrigin(Handle<Script> script,
Handle<SharedFunctionInfo> outer_info, Handle<SharedFunctionInfo> outer_info,
int eval_position) { int eval_position) {
if (eval_position == RelocInfo::kNoPosition) { if (eval_position == kNoSourcePosition) {
// If the position is missing, attempt to get the code offset from the // If the position is missing, attempt to get the code offset from the
// current activation. Do not translate the code offset into source // current activation. Do not translate the code offset into source
// position, but store it as negative value for lazy translation. // position, but store it as negative value for lazy translation.
@ -17077,7 +17078,7 @@ Handle<Object> CompilationCacheTable::Lookup(Handle<String> src,
LanguageMode language_mode) { LanguageMode language_mode) {
Isolate* isolate = GetIsolate(); Isolate* isolate = GetIsolate();
Handle<SharedFunctionInfo> shared(context->closure()->shared()); Handle<SharedFunctionInfo> shared(context->closure()->shared());
StringSharedKey key(src, shared, language_mode, RelocInfo::kNoPosition); StringSharedKey key(src, shared, language_mode, kNoSourcePosition);
int entry = FindEntry(&key); int entry = FindEntry(&key);
if (entry == kNotFound) return isolate->factory()->undefined_value(); if (entry == kNotFound) return isolate->factory()->undefined_value();
int index = EntryToIndex(entry); int index = EntryToIndex(entry);
@ -17117,7 +17118,7 @@ Handle<CompilationCacheTable> CompilationCacheTable::Put(
Handle<Context> context, LanguageMode language_mode, Handle<Object> value) { Handle<Context> context, LanguageMode language_mode, Handle<Object> value) {
Isolate* isolate = cache->GetIsolate(); Isolate* isolate = cache->GetIsolate();
Handle<SharedFunctionInfo> shared(context->closure()->shared()); Handle<SharedFunctionInfo> shared(context->closure()->shared());
StringSharedKey key(src, shared, language_mode, RelocInfo::kNoPosition); StringSharedKey key(src, shared, language_mode, kNoSourcePosition);
Handle<Object> k = key.AsHandle(isolate); Handle<Object> k = key.AsHandle(isolate);
cache = EnsureCapacity(cache, 1, &key); cache = EnsureCapacity(cache, 1, &key);
int entry = cache->FindInsertionEntry(key.Hash()); int entry = cache->FindInsertionEntry(key.Hash());

View File

@ -8,6 +8,7 @@
#include "src/ast/scopes.h" #include "src/ast/scopes.h"
#include "src/bailout-reason.h" #include "src/bailout-reason.h"
#include "src/base/hashmap.h" #include "src/base/hashmap.h"
#include "src/globals.h"
#include "src/messages.h" #include "src/messages.h"
#include "src/parsing/expression-classifier.h" #include "src/parsing/expression-classifier.h"
#include "src/parsing/func-name-inferrer.h" #include "src/parsing/func-name-inferrer.h"
@ -1978,7 +1979,7 @@ ParserBase<Traits>::ParsePropertyDefinition(
classifier->Accumulate(&rhs_classifier, classifier->Accumulate(&rhs_classifier,
ExpressionClassifier::ExpressionProductions); ExpressionClassifier::ExpressionProductions);
value = factory()->NewAssignment(Token::ASSIGN, lhs, rhs, value = factory()->NewAssignment(Token::ASSIGN, lhs, rhs,
RelocInfo::kNoPosition); kNoSourcePosition);
classifier->RecordCoverInitializedNameError( classifier->RecordCoverInitializedNameError(
Scanner::Location(next_beg_pos, scanner()->location().end_pos), Scanner::Location(next_beg_pos, scanner()->location().end_pos),
MessageTemplate::kInvalidCoverInitializedName); MessageTemplate::kInvalidCoverInitializedName);
@ -2032,8 +2033,8 @@ ParserBase<Traits>::ParsePropertyDefinition(
value = this->ParseFunctionLiteral( value = this->ParseFunctionLiteral(
*name, scanner()->location(), kSkipFunctionNameCheck, kind, *name, scanner()->location(), kSkipFunctionNameCheck, kind,
RelocInfo::kNoPosition, FunctionLiteral::kAccessorOrMethod, kNoSourcePosition, FunctionLiteral::kAccessorOrMethod, language_mode(),
language_mode(), CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
return factory()->NewObjectLiteralProperty(name_expression, value, return factory()->NewObjectLiteralProperty(name_expression, value,
ObjectLiteralProperty::COMPUTED, ObjectLiteralProperty::COMPUTED,
@ -2071,8 +2072,8 @@ ParserBase<Traits>::ParsePropertyDefinition(
typename Traits::Type::FunctionLiteral value = this->ParseFunctionLiteral( typename Traits::Type::FunctionLiteral value = this->ParseFunctionLiteral(
*name, scanner()->location(), kSkipFunctionNameCheck, *name, scanner()->location(), kSkipFunctionNameCheck,
is_get ? FunctionKind::kGetterFunction : FunctionKind::kSetterFunction, is_get ? FunctionKind::kGetterFunction : FunctionKind::kSetterFunction,
RelocInfo::kNoPosition, FunctionLiteral::kAccessorOrMethod, kNoSourcePosition, FunctionLiteral::kAccessorOrMethod, language_mode(),
language_mode(), CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
// Make sure the name expression is a string since we need a Name for // Make sure the name expression is a string since we need a Name for
// Runtime_DefineAccessorPropertyUnchecked and since we can determine this // Runtime_DefineAccessorPropertyUnchecked and since we can determine this
@ -3365,7 +3366,7 @@ ParserBase<Traits>::ParseArrowFunctionLiteral(
} }
} else { } else {
body = this->ParseEagerFunctionBody( body = this->ParseEagerFunctionBody(
this->EmptyIdentifier(), RelocInfo::kNoPosition, formal_parameters, this->EmptyIdentifier(), kNoSourcePosition, formal_parameters,
arrow_kind, FunctionLiteral::kAnonymousExpression, CHECK_OK); arrow_kind, FunctionLiteral::kAnonymousExpression, CHECK_OK);
materialized_literal_count = materialized_literal_count =
function_state.materialized_literal_count(); function_state.materialized_literal_count();

File diff suppressed because it is too large Load Diff

View File

@ -505,7 +505,7 @@ class ParserTraits {
const AstRawString* GetNumberAsSymbol(Scanner* scanner); const AstRawString* GetNumberAsSymbol(Scanner* scanner);
Expression* ThisExpression(Scope* scope, AstNodeFactory* factory, Expression* ThisExpression(Scope* scope, AstNodeFactory* factory,
int pos = RelocInfo::kNoPosition); int pos = kNoSourcePosition);
Expression* SuperPropertyReference(Scope* scope, AstNodeFactory* factory, Expression* SuperPropertyReference(Scope* scope, AstNodeFactory* factory,
int pos); int pos);
Expression* SuperCallReference(Scope* scope, AstNodeFactory* factory, Expression* SuperCallReference(Scope* scope, AstNodeFactory* factory,
@ -971,7 +971,7 @@ class Parser : public ParserBase<ParserTraits> {
int each_keyword_pos); int each_keyword_pos);
void InitializeForOfStatement(ForOfStatement* stmt, Expression* each, void InitializeForOfStatement(ForOfStatement* stmt, Expression* each,
Expression* iterable, Statement* body, Expression* iterable, Statement* body,
int next_result_pos = RelocInfo::kNoPosition); int next_result_pos = kNoSourcePosition);
Statement* DesugarLexicalBindingsInForStatement( Statement* DesugarLexicalBindingsInForStatement(
Scope* inner_scope, VariableMode mode, Scope* inner_scope, VariableMode mode,
ZoneList<const AstRawString*>* names, ForStatement* loop, Statement* init, ZoneList<const AstRawString*>* names, ForStatement* loop, Statement* init,

View File

@ -159,7 +159,7 @@ void Parser::PatternRewriter::VisitVariableProxy(VariableProxy* pattern) {
DCHECK(!proxy->is_resolved() || proxy->var() == var); DCHECK(!proxy->is_resolved() || proxy->var() == var);
var->set_initializer_position(initializer_position_); var->set_initializer_position(initializer_position_);
DCHECK(initializer_position_ != RelocInfo::kNoPosition); DCHECK(initializer_position_ != kNoSourcePosition);
Scope* declaration_scope = IsLexicalVariableMode(descriptor_->mode) Scope* declaration_scope = IsLexicalVariableMode(descriptor_->mode)
? descriptor_->scope ? descriptor_->scope
@ -248,7 +248,7 @@ void Parser::PatternRewriter::VisitVariableProxy(VariableProxy* pattern) {
// We may want to pass singleton to avoid Literal allocations. // We may want to pass singleton to avoid Literal allocations.
LanguageMode language_mode = initialization_scope->language_mode(); LanguageMode language_mode = initialization_scope->language_mode();
arguments->Add( arguments->Add(
factory()->NewNumberLiteral(language_mode, RelocInfo::kNoPosition), factory()->NewNumberLiteral(language_mode, kNoSourcePosition),
zone()); zone());
// Be careful not to assign a value to the global variable if // Be careful not to assign a value to the global variable if
@ -310,10 +310,10 @@ Variable* Parser::PatternRewriter::CreateTempVar(Expression* value) {
if (value != nullptr) { if (value != nullptr) {
auto assignment = factory()->NewAssignment( auto assignment = factory()->NewAssignment(
Token::ASSIGN, factory()->NewVariableProxy(temp), value, Token::ASSIGN, factory()->NewVariableProxy(temp), value,
RelocInfo::kNoPosition); kNoSourcePosition);
block_->statements()->Add( block_->statements()->Add(
factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition), factory()->NewExpressionStatement(assignment, kNoSourcePosition),
zone()); zone());
} }
return temp; return temp;
@ -348,11 +348,10 @@ void Parser::PatternRewriter::VisitRewritableExpression(
auto temp_var = CreateTempVar(current_value_); auto temp_var = CreateTempVar(current_value_);
Expression* is_undefined = factory()->NewCompareOperation( Expression* is_undefined = factory()->NewCompareOperation(
Token::EQ_STRICT, factory()->NewVariableProxy(temp_var), Token::EQ_STRICT, factory()->NewVariableProxy(temp_var),
factory()->NewUndefinedLiteral(RelocInfo::kNoPosition), factory()->NewUndefinedLiteral(kNoSourcePosition), kNoSourcePosition);
RelocInfo::kNoPosition);
value = factory()->NewConditional(is_undefined, initializer, value = factory()->NewConditional(is_undefined, initializer,
factory()->NewVariableProxy(temp_var), factory()->NewVariableProxy(temp_var),
RelocInfo::kNoPosition); kNoSourcePosition);
} }
PatternContext old_context = SetAssignmentContextIfNeeded(initializer); PatternContext old_context = SetAssignmentContextIfNeeded(initializer);
@ -429,7 +428,7 @@ void Parser::PatternRewriter::VisitObjectLiteral(ObjectLiteral* pattern,
RecurseIntoSubpattern( RecurseIntoSubpattern(
property->value(), property->value(),
factory()->NewProperty(factory()->NewVariableProxy(temp), factory()->NewProperty(factory()->NewVariableProxy(temp),
property->key(), RelocInfo::kNoPosition)); property->key(), kNoSourcePosition));
set_context(context); set_context(context);
} }
} }
@ -447,13 +446,13 @@ void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node,
auto temp = *temp_var = CreateTempVar(current_value_); auto temp = *temp_var = CreateTempVar(current_value_);
auto iterator = CreateTempVar(parser_->GetIterator( auto iterator = CreateTempVar(parser_->GetIterator(
factory()->NewVariableProxy(temp), factory(), RelocInfo::kNoPosition)); factory()->NewVariableProxy(temp), factory(), kNoSourcePosition));
auto done = CreateTempVar( auto done =
factory()->NewBooleanLiteral(false, RelocInfo::kNoPosition)); CreateTempVar(factory()->NewBooleanLiteral(false, kNoSourcePosition));
auto result = CreateTempVar(); auto result = CreateTempVar();
auto v = CreateTempVar(); auto v = CreateTempVar();
auto completion = CreateTempVar(); auto completion = CreateTempVar();
auto nopos = RelocInfo::kNoPosition; auto nopos = kNoSourcePosition;
// For the purpose of iterator finalization, we temporarily set block_ to a // For the purpose of iterator finalization, we temporarily set block_ to a
// new block. In the main body of this function, we write to block_ (both // new block. In the main body of this function, we write to block_ (both
@ -487,30 +486,29 @@ void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node,
auto result_done = factory()->NewProperty( auto result_done = factory()->NewProperty(
factory()->NewVariableProxy(result), factory()->NewVariableProxy(result),
factory()->NewStringLiteral(ast_value_factory()->done_string(), factory()->NewStringLiteral(ast_value_factory()->done_string(),
RelocInfo::kNoPosition), kNoSourcePosition),
RelocInfo::kNoPosition); kNoSourcePosition);
auto assign_undefined = factory()->NewAssignment( auto assign_undefined = factory()->NewAssignment(
Token::ASSIGN, factory()->NewVariableProxy(v), Token::ASSIGN, factory()->NewVariableProxy(v),
factory()->NewUndefinedLiteral(RelocInfo::kNoPosition), factory()->NewUndefinedLiteral(kNoSourcePosition), kNoSourcePosition);
RelocInfo::kNoPosition);
auto assign_value = factory()->NewAssignment( auto assign_value = factory()->NewAssignment(
Token::ASSIGN, factory()->NewVariableProxy(v), Token::ASSIGN, factory()->NewVariableProxy(v),
factory()->NewProperty( factory()->NewProperty(
factory()->NewVariableProxy(result), factory()->NewVariableProxy(result),
factory()->NewStringLiteral(ast_value_factory()->value_string(), factory()->NewStringLiteral(ast_value_factory()->value_string(),
RelocInfo::kNoPosition), kNoSourcePosition),
RelocInfo::kNoPosition), kNoSourcePosition),
RelocInfo::kNoPosition); kNoSourcePosition);
auto unset_done = factory()->NewAssignment( auto unset_done = factory()->NewAssignment(
Token::ASSIGN, factory()->NewVariableProxy(done), Token::ASSIGN, factory()->NewVariableProxy(done),
factory()->NewBooleanLiteral(false, RelocInfo::kNoPosition), factory()->NewBooleanLiteral(false, kNoSourcePosition),
RelocInfo::kNoPosition); kNoSourcePosition);
auto inner_else = auto inner_else =
factory()->NewBlock(nullptr, 2, true, RelocInfo::kNoPosition); factory()->NewBlock(nullptr, 2, true, kNoSourcePosition);
inner_else->statements()->Add( inner_else->statements()->Add(
factory()->NewExpressionStatement(assign_value, nopos), zone()); factory()->NewExpressionStatement(assign_value, nopos), zone());
inner_else->statements()->Add( inner_else->statements()->Add(
@ -522,7 +520,7 @@ void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node,
inner_else, nopos); inner_else, nopos);
auto next_block = auto next_block =
factory()->NewBlock(nullptr, 3, true, RelocInfo::kNoPosition); factory()->NewBlock(nullptr, 3, true, kNoSourcePosition);
next_block->statements()->Add( next_block->statements()->Add(
factory()->NewExpressionStatement( factory()->NewExpressionStatement(
factory()->NewAssignment( factory()->NewAssignment(
@ -534,17 +532,16 @@ void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node,
factory()->NewExpressionStatement( factory()->NewExpressionStatement(
parser_->BuildIteratorNextResult( parser_->BuildIteratorNextResult(
factory()->NewVariableProxy(iterator), result, factory()->NewVariableProxy(iterator), result,
RelocInfo::kNoPosition), kNoSourcePosition),
RelocInfo::kNoPosition), kNoSourcePosition),
zone()); zone());
next_block->statements()->Add(inner_if, zone()); next_block->statements()->Add(inner_if, zone());
if_not_done = factory()->NewIfStatement( if_not_done = factory()->NewIfStatement(
factory()->NewUnaryOperation(Token::NOT, factory()->NewUnaryOperation(
factory()->NewVariableProxy(done), Token::NOT, factory()->NewVariableProxy(done), kNoSourcePosition),
RelocInfo::kNoPosition), next_block, factory()->NewEmptyStatement(kNoSourcePosition),
next_block, factory()->NewEmptyStatement(RelocInfo::kNoPosition), kNoSourcePosition);
RelocInfo::kNoPosition);
} }
block_->statements()->Add(if_not_done, zone()); block_->statements()->Add(if_not_done, zone());
@ -596,7 +593,7 @@ void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node,
empty_exprs, empty_exprs,
// Reuse pattern's literal index - it is unused since there is no // Reuse pattern's literal index - it is unused since there is no
// actual literal allocated. // actual literal allocated.
node->literal_index(), RelocInfo::kNoPosition)); node->literal_index(), kNoSourcePosition));
} }
// done = true; // done = true;
@ -702,11 +699,10 @@ void Parser::PatternRewriter::VisitAssignment(Assignment* node) {
if (IsInitializerContext()) { if (IsInitializerContext()) {
Expression* is_undefined = factory()->NewCompareOperation( Expression* is_undefined = factory()->NewCompareOperation(
Token::EQ_STRICT, factory()->NewVariableProxy(temp), Token::EQ_STRICT, factory()->NewVariableProxy(temp),
factory()->NewUndefinedLiteral(RelocInfo::kNoPosition), factory()->NewUndefinedLiteral(kNoSourcePosition), kNoSourcePosition);
RelocInfo::kNoPosition);
value = factory()->NewConditional(is_undefined, initializer, value = factory()->NewConditional(is_undefined, initializer,
factory()->NewVariableProxy(temp), factory()->NewVariableProxy(temp),
RelocInfo::kNoPosition); kNoSourcePosition);
} }
// Initializer may have been parsed in the wrong scope. // Initializer may have been parsed in the wrong scope.
@ -728,8 +724,7 @@ void Parser::PatternRewriter::VisitProperty(v8::internal::Property* node) {
factory()->NewAssignment(Token::ASSIGN, node, value, node->position()); factory()->NewAssignment(Token::ASSIGN, node, value, node->position());
block_->statements()->Add( block_->statements()->Add(
factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition), factory()->NewExpressionStatement(assignment, kNoSourcePosition), zone());
zone());
} }

View File

@ -292,7 +292,7 @@ class PreParserExpression {
void set_index(int index) {} // For YieldExpressions void set_index(int index) {} // For YieldExpressions
void set_should_eager_compile() {} void set_should_eager_compile() {}
int position() const { return RelocInfo::kNoPosition; } int position() const { return kNoSourcePosition; }
void set_function_token_position(int position) {} void set_function_token_position(int position) {}
private: private:

View File

@ -51,7 +51,7 @@ class Processor: public AstVisitor {
result_assigned_ = true; result_assigned_ = true;
VariableProxy* result_proxy = factory()->NewVariableProxy(result_); VariableProxy* result_proxy = factory()->NewVariableProxy(result_);
return factory()->NewAssignment(Token::ASSIGN, result_proxy, value, return factory()->NewAssignment(Token::ASSIGN, result_proxy, value,
RelocInfo::kNoPosition); kNoSourcePosition);
} }
// Inserts '.result = undefined' in front of the given statement. // Inserts '.result = undefined' in front of the given statement.
@ -93,13 +93,12 @@ class Processor: public AstVisitor {
Statement* Processor::AssignUndefinedBefore(Statement* s) { Statement* Processor::AssignUndefinedBefore(Statement* s) {
Expression* result_proxy = factory()->NewVariableProxy(result_); Expression* result_proxy = factory()->NewVariableProxy(result_);
Expression* undef = factory()->NewUndefinedLiteral(RelocInfo::kNoPosition); Expression* undef = factory()->NewUndefinedLiteral(kNoSourcePosition);
Expression* assignment = factory()->NewAssignment( Expression* assignment = factory()->NewAssignment(Token::ASSIGN, result_proxy,
Token::ASSIGN, result_proxy, undef, RelocInfo::kNoPosition); undef, kNoSourcePosition);
Block* b = factory()->NewBlock(NULL, 2, false, RelocInfo::kNoPosition); Block* b = factory()->NewBlock(NULL, 2, false, kNoSourcePosition);
b->statements()->Add( b->statements()->Add(
factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition), factory()->NewExpressionStatement(assignment, kNoSourcePosition), zone());
zone());
b->statements()->Add(s, zone()); b->statements()->Add(s, zone());
return b; return b;
} }
@ -232,15 +231,13 @@ void Processor::VisitTryFinallyStatement(TryFinallyStatement* node) {
Expression* backup_proxy = factory()->NewVariableProxy(backup); Expression* backup_proxy = factory()->NewVariableProxy(backup);
Expression* result_proxy = factory()->NewVariableProxy(result_); Expression* result_proxy = factory()->NewVariableProxy(result_);
Expression* save = factory()->NewAssignment( Expression* save = factory()->NewAssignment(
Token::ASSIGN, backup_proxy, result_proxy, RelocInfo::kNoPosition); Token::ASSIGN, backup_proxy, result_proxy, kNoSourcePosition);
Expression* restore = factory()->NewAssignment( Expression* restore = factory()->NewAssignment(
Token::ASSIGN, result_proxy, backup_proxy, RelocInfo::kNoPosition); Token::ASSIGN, result_proxy, backup_proxy, kNoSourcePosition);
node->finally_block()->statements()->InsertAt( node->finally_block()->statements()->InsertAt(
0, factory()->NewExpressionStatement(save, RelocInfo::kNoPosition), 0, factory()->NewExpressionStatement(save, kNoSourcePosition), zone());
zone());
node->finally_block()->statements()->Add( node->finally_block()->statements()->Add(
factory()->NewExpressionStatement(restore, RelocInfo::kNoPosition), factory()->NewExpressionStatement(restore, kNoSourcePosition), zone());
zone());
} }
is_set_ = set_after; is_set_ = set_after;
Visit(node->try_block()); Visit(node->try_block());
@ -355,7 +352,7 @@ bool Rewriter::Rewrite(ParseInfo* info) {
if (processor.HasStackOverflow()) return false; if (processor.HasStackOverflow()) return false;
if (processor.result_assigned()) { if (processor.result_assigned()) {
int pos = RelocInfo::kNoPosition; int pos = kNoSourcePosition;
VariableProxy* result_proxy = VariableProxy* result_proxy =
processor.factory()->NewVariableProxy(result, pos); processor.factory()->NewVariableProxy(result, pos);
Statement* result_statement = Statement* result_statement =
@ -383,8 +380,7 @@ bool Rewriter::Rewrite(Parser* parser, DoExpression* expr,
if (!processor.result_assigned()) { if (!processor.result_assigned()) {
AstNodeFactory* node_factory = processor.factory(); AstNodeFactory* node_factory = processor.factory();
Expression* undef = Expression* undef = node_factory->NewUndefinedLiteral(kNoSourcePosition);
node_factory->NewUndefinedLiteral(RelocInfo::kNoPosition);
Statement* completion = node_factory->NewExpressionStatement( Statement* completion = node_factory->NewExpressionStatement(
processor.SetResult(undef), expr->position()); processor.SetResult(undef), expr->position());
body->Add(completion, factory->zone()); body->Add(completion, factory->zone());

View File

@ -10,6 +10,7 @@
#include "src/debug/debug-scopes.h" #include "src/debug/debug-scopes.h"
#include "src/debug/debug.h" #include "src/debug/debug.h"
#include "src/frames-inl.h" #include "src/frames-inl.h"
#include "src/globals.h"
#include "src/interpreter/bytecodes.h" #include "src/interpreter/bytecodes.h"
#include "src/interpreter/interpreter.h" #include "src/interpreter/interpreter.h"
#include "src/isolate-inl.h" #include "src/isolate-inl.h"
@ -563,7 +564,7 @@ RUNTIME_FUNCTION(Runtime_GetFrameDetails) {
details->set(kFrameDetailsLocalCountIndex, Smi::FromInt(0)); details->set(kFrameDetailsLocalCountIndex, Smi::FromInt(0));
// Add the source position. // Add the source position.
if (position != RelocInfo::kNoPosition) { if (position != kNoSourcePosition) {
details->set(kFrameDetailsSourcePositionIndex, Smi::FromInt(position)); details->set(kFrameDetailsSourcePositionIndex, Smi::FromInt(position));
} }
@ -703,7 +704,7 @@ RUNTIME_FUNCTION(Runtime_GetFrameDetails) {
details->set(kFrameDetailsLocalCountIndex, Smi::FromInt(local_count)); details->set(kFrameDetailsLocalCountIndex, Smi::FromInt(local_count));
// Add the source position. // Add the source position.
if (position != RelocInfo::kNoPosition) { if (position != kNoSourcePosition) {
details->set(kFrameDetailsSourcePositionIndex, Smi::FromInt(position)); details->set(kFrameDetailsSourcePositionIndex, Smi::FromInt(position));
} else { } else {
details->set(kFrameDetailsSourcePositionIndex, heap->undefined_value()); details->set(kFrameDetailsSourcePositionIndex, heap->undefined_value());

View File

@ -7,8 +7,8 @@
#include <ostream> #include <ostream>
#include "src/assembler.h"
#include "src/flags.h" #include "src/flags.h"
#include "src/globals.h"
#include "src/utils.h" #include "src/utils.h"
namespace v8 { namespace v8 {
@ -49,8 +49,7 @@ class SourcePosition {
uint32_t raw() const { return value_; } uint32_t raw() const { return value_; }
private: private:
static const uint32_t kNoPosition = static const uint32_t kNoPosition = static_cast<uint32_t>(kNoSourcePosition);
static_cast<uint32_t>(RelocInfo::kNoPosition);
typedef BitField<uint32_t, 0, 9> InliningIdField; typedef BitField<uint32_t, 0, 9> InliningIdField;
// Offset from the start of the inlined function. // Offset from the start of the inlined function.

View File

@ -19,7 +19,7 @@ namespace internal {
#define FAIL(node, msg) \ #define FAIL(node, msg) \
do { \ do { \
valid_ = false; \ valid_ = false; \
int line = node->position() == RelocInfo::kNoPosition \ int line = node->position() == kNoSourcePosition \
? -1 \ ? -1 \
: script_->GetLineNumber(node->position()); \ : script_->GetLineNumber(node->position()); \
base::OS::SNPrintF(error_message_, sizeof(error_message_), \ base::OS::SNPrintF(error_message_, sizeof(error_message_), \
@ -27,7 +27,6 @@ namespace internal {
return; \ return; \
} while (false) } while (false)
#define RECURSE(call) \ #define RECURSE(call) \
do { \ do { \
DCHECK(!HasStackOverflow()); \ DCHECK(!HasStackOverflow()); \

View File

@ -42,7 +42,7 @@ TEST(List) {
Zone zone(&allocator); Zone zone(&allocator);
AstValueFactory value_factory(&zone, 0); AstValueFactory value_factory(&zone, 0);
AstNodeFactory factory(&value_factory); AstNodeFactory factory(&value_factory);
AstNode* node = factory.NewEmptyStatement(RelocInfo::kNoPosition); AstNode* node = factory.NewEmptyStatement(kNoSourcePosition);
list->Add(node); list->Add(node);
CHECK_EQ(1, list->length()); CHECK_EQ(1, list->length());
CHECK_EQ(node, list->at(0)); CHECK_EQ(node, list->at(0));