Commit d317145d authored by adamk's avatar adamk Committed by Commit bot

Eagerly extract stack limit from Isolate in InitializeAstVisitor()

Previously, any AstVisitor subclasses which wanted to make use of
the shared stack overflow checking code needed to depend on Isolate.

With this patch, it will be easy to create a second InitializeAstVisitor
overload taking a stack_limit directly, for use in code that has no
Isolate available (such as code running in the parser).

AstVisitor subclasses which depended upon the isolate() accessor have
been fixed to either have their own isolate_ member or get it from
somewhere else convenient.

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

Cr-Commit-Position: refs/heads/master@{#31260}
parent 0c81c4e9
......@@ -14,6 +14,7 @@ class AstNumberingVisitor final : public AstVisitor {
public:
AstNumberingVisitor(Isolate* isolate, Zone* zone)
: AstVisitor(),
isolate_(isolate),
next_id_(BailoutId::FirstUsable().ToInt()),
properties_(zone),
slot_cache_(zone),
......@@ -65,12 +66,13 @@ class AstNumberingVisitor final : public AstVisitor {
template <typename Node>
void ReserveFeedbackSlots(Node* node) {
node->AssignFeedbackVectorSlots(isolate(), properties_.get_spec(),
node->AssignFeedbackVectorSlots(isolate_, properties_.get_spec(),
&slot_cache_);
}
BailoutReason dont_optimize_reason() const { return dont_optimize_reason_; }
Isolate* isolate_;
int next_id_;
AstProperties properties_;
// The slot cache allows us to reuse certain feedback vector slots.
......@@ -466,7 +468,7 @@ void AstNumberingVisitor::VisitObjectLiteral(ObjectLiteral* node) {
for (int i = 0; i < node->properties()->length(); i++) {
VisitObjectLiteralProperty(node->properties()->at(i));
}
node->BuildConstantProperties(isolate());
node->BuildConstantProperties(isolate_);
// Mark all computed expressions that are bound to a key that
// is shadowed by a later occurrence of the same key. For the
// marked expressions, no store code will be is emitted.
......@@ -489,7 +491,7 @@ void AstNumberingVisitor::VisitArrayLiteral(ArrayLiteral* node) {
for (int i = 0; i < node->values()->length(); i++) {
Visit(node->values()->at(i));
}
node->BuildConstantElements(isolate());
node->BuildConstantElements(isolate_);
ReserveFeedbackSlots(node);
}
......
......@@ -3182,23 +3182,23 @@ class AstVisitor BASE_EMBEDDED {
\
bool CheckStackOverflow() { \
if (stack_overflow_) return true; \
StackLimitCheck check(isolate_); \
if (!check.HasOverflowed()) return false; \
stack_overflow_ = true; \
return true; \
if (GetCurrentStackPosition() < stack_limit_) { \
stack_overflow_ = true; \
return true; \
} \
return false; \
} \
\
private: \
void InitializeAstVisitor(Isolate* isolate, Zone* zone) { \
isolate_ = isolate; \
zone_ = zone; \
stack_limit_ = isolate->stack_guard()->real_climit(); \
stack_overflow_ = false; \
} \
Zone* zone() { return zone_; } \
Isolate* isolate() { return isolate_; } \
\
Isolate* isolate_; \
Zone* zone_; \
uintptr_t stack_limit_; \
bool stack_overflow_
......
......@@ -3017,6 +3017,9 @@ void AstGraphBuilder::VisitLogicalExpression(BinaryOperation* expr) {
}
Isolate* AstGraphBuilder::isolate() const { return info()->isolate(); }
LanguageMode AstGraphBuilder::language_mode() const {
return info()->language_mode();
}
......
......@@ -129,6 +129,7 @@ class AstGraphBuilder : public AstVisitor {
ContextScope* execution_context() const { return execution_context_; }
CommonOperatorBuilder* common() const { return jsgraph_->common(); }
CompilationInfo* info() const { return info_; }
Isolate* isolate() const;
LanguageMode language_mode() const;
JSGraph* jsgraph() { return jsgraph_; }
Graph* graph() { return jsgraph_->graph(); }
......
......@@ -688,6 +688,7 @@ class FullCodeGenerator: public AstVisitor {
const ExpressionContext* context() { return context_; }
void set_new_context(const ExpressionContext* context) { context_ = context; }
Isolate* isolate() const { return info_->isolate(); }
Handle<Script> script() { return info_->script(); }
bool is_eval() { return info_->is_eval(); }
bool is_native() { return info_->is_native(); }
......
......@@ -132,7 +132,8 @@ void BytecodeGenerator::ControlScope::PerformCommand(Command command,
BytecodeGenerator::BytecodeGenerator(Isolate* isolate, Zone* zone)
: builder_(isolate, zone),
: isolate_(isolate),
builder_(isolate, zone),
info_(nullptr),
scope_(nullptr),
globals_(0, zone),
......
......@@ -54,6 +54,8 @@ class BytecodeGenerator : public AstVisitor {
inline BytecodeArrayBuilder* builder() { return &builder_; }
inline Isolate* isolate() const { return isolate_; }
inline Scope* scope() const { return scope_; }
inline void set_scope(Scope* scope) { scope_ = scope; }
inline CompilationInfo* info() const { return info_; }
......@@ -71,6 +73,7 @@ class BytecodeGenerator : public AstVisitor {
Strength language_mode_strength() const;
int feedback_index(FeedbackVectorSlot slot) const;
Isolate* isolate_;
BytecodeArrayBuilder builder_;
CompilationInfo* info_;
Scope* scope_;
......
......@@ -17,7 +17,8 @@ namespace internal {
AstTyper::AstTyper(Isolate* isolate, Zone* zone, Handle<JSFunction> closure,
Scope* scope, BailoutId osr_ast_id, FunctionLiteral* root)
: closure_(closure),
: isolate_(isolate),
closure_(closure),
scope_(scope),
osr_ast_id_(osr_ast_id),
root_(root),
......@@ -51,7 +52,7 @@ void AstTyper::ObserveTypesAtOsrEntry(IterationStatement* stmt) {
if (stmt->OsrEntryId() != osr_ast_id_) return;
DisallowHeapAllocation no_gc;
JavaScriptFrameIterator it(isolate());
JavaScriptFrameIterator it(isolate_);
JavaScriptFrame* frame = it.frame();
// Assert that the frame on the stack belongs to the function we want to OSR.
......@@ -529,7 +530,7 @@ void AstTyper::VisitCall(Call* expr) {
// Collect type feedback.
RECURSE(Visit(expr->expression()));
bool is_uninitialized = true;
if (expr->IsUsingCallFeedbackICSlot(isolate())) {
if (expr->IsUsingCallFeedbackICSlot(isolate_)) {
FeedbackVectorSlot slot = expr->CallFeedbackICSlot();
is_uninitialized = oracle()->CallIsUninitialized(slot);
if (!expr->expression()->IsProperty() &&
......@@ -549,7 +550,7 @@ void AstTyper::VisitCall(Call* expr) {
}
VariableProxy* proxy = expr->expression()->AsVariableProxy();
if (proxy != NULL && proxy->var()->is_possibly_eval(isolate())) {
if (proxy != NULL && proxy->var()->is_possibly_eval(isolate_)) {
store_.Forget(); // Eval could do whatever to local variables.
}
......
......@@ -33,6 +33,7 @@ class AstTyper: public AstVisitor {
typedef v8::internal::Effects<int, kNoVar> Effects;
typedef v8::internal::NestedEffects<int, kNoVar> Store;
Isolate* isolate_;
Handle<JSFunction> closure_;
Scope* scope_;
BailoutId osr_ast_id_;
......
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