Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
[ic] Don't share LoadGlobalIC slots inside typeof and outside typeof.
Browse files Browse the repository at this point in the history
Because in case of interceptors we will install a slow stub that suits only one case.

BUG=chromium:634467
[email protected]

Review-Url: https://codereview.chromium.org/2219303002
Cr-Commit-Position: refs/heads/master@{#38503}
  • Loading branch information
isheludko authored and Commit bot committed Aug 9, 2016
1 parent 01766cd commit d634e65
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/ast/ast-numbering.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> {
yield_count_(0),
properties_(zone),
slot_cache_(zone),
slot_cache_inside_typeof_(zone),
dont_optimize_reason_(kNoReason),
typeof_mode_(NOT_INSIDE_TYPEOF),
catch_prediction_(HandlerTable::UNCAUGHT) {
InitializeAstVisitor(isolate);
}
Expand Down Expand Up @@ -62,7 +64,9 @@ class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> {
template <typename Node>
void ReserveFeedbackSlots(Node* node) {
node->AssignFeedbackVectorSlots(isolate_, properties_.get_spec(),
&slot_cache_);
typeof_mode_ == INSIDE_TYPEOF
? &slot_cache_inside_typeof_
: &slot_cache_);
}

BailoutReason dont_optimize_reason() const { return dont_optimize_reason_; }
Expand All @@ -74,7 +78,9 @@ class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> {
AstProperties properties_;
// The slot cache allows us to reuse certain feedback vector slots.
FeedbackVectorSlotCache slot_cache_;
FeedbackVectorSlotCache slot_cache_inside_typeof_;
BailoutReason dont_optimize_reason_;
TypeofMode typeof_mode_;
HandlerTable::CatchPrediction catch_prediction_;

DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
Expand Down Expand Up @@ -216,9 +222,13 @@ void AstNumberingVisitor::VisitThrow(Throw* node) {


void AstNumberingVisitor::VisitUnaryOperation(UnaryOperation* node) {
Token::Value op = node->op();
TypeofMode old_typeof_mode = typeof_mode_;
IncrementNodeCount();
if (op == Token::TYPEOF) typeof_mode_ = INSIDE_TYPEOF;
node->set_base_id(ReserveIdRange(UnaryOperation::num_ids()));
Visit(node->expression());
typeof_mode_ = old_typeof_mode;
}


Expand Down
18 changes: 16 additions & 2 deletions test/cctest/test-api-interceptors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,21 @@ THREADED_TEST(InterceptorLoadGlobalICGlobalWithInterceptor) {
v8::Local<Value> value = CompileRun(
"var f = function() { "
" try {"
" x;"
" x1;"
" } catch(e) {"
" }"
" return typeof x1 === 'undefined';"
"};"
"for (var i = 0; i < 10; i++) {"
" f();"
"};"
"f();");
CHECK_EQ(true, value->BooleanValue(context.local()).FromJust());

value = CompileRun(
"var f = function() { "
" try {"
" x2;"
" return false;"
" } catch(e) {"
" return true;"
Expand All @@ -888,7 +902,7 @@ THREADED_TEST(InterceptorLoadGlobalICGlobalWithInterceptor) {
value = CompileRun(
"var f = function() { "
" try {"
" typeof(x);"
" typeof(x3);"
" return true;"
" } catch(e) {"
" return false;"
Expand Down

0 comments on commit d634e65

Please sign in to comment.