From d634e65fb07fb7c3a79680237c5e90a9fae6645c Mon Sep 17 00:00:00 2001 From: ishell Date: Tue, 9 Aug 2016 09:30:25 -0700 Subject: [PATCH] [ic] Don't share LoadGlobalIC slots inside typeof and outside typeof. Because in case of interceptors we will install a slow stub that suits only one case. BUG=chromium:634467 TBR=verwaest@chromium.org Review-Url: https://codereview.chromium.org/2219303002 Cr-Commit-Position: refs/heads/master@{#38503} --- src/ast/ast-numbering.cc | 12 +++++++++++- test/cctest/test-api-interceptors.cc | 18 ++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/ast/ast-numbering.cc b/src/ast/ast-numbering.cc index 100814691f8..1c2ce3ccfd1 100644 --- a/src/ast/ast-numbering.cc +++ b/src/ast/ast-numbering.cc @@ -19,7 +19,9 @@ class AstNumberingVisitor final : public AstVisitor { 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); } @@ -62,7 +64,9 @@ class AstNumberingVisitor final : public AstVisitor { template 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_; } @@ -74,7 +78,9 @@ class AstNumberingVisitor final : public AstVisitor { 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(); @@ -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; } diff --git a/test/cctest/test-api-interceptors.cc b/test/cctest/test-api-interceptors.cc index 3e2d8dc5be7..1636e4bdce5 100644 --- a/test/cctest/test-api-interceptors.cc +++ b/test/cctest/test-api-interceptors.cc @@ -873,7 +873,21 @@ THREADED_TEST(InterceptorLoadGlobalICGlobalWithInterceptor) { v8::Local 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;" @@ -888,7 +902,7 @@ THREADED_TEST(InterceptorLoadGlobalICGlobalWithInterceptor) { value = CompileRun( "var f = function() { " " try {" - " typeof(x);" + " typeof(x3);" " return true;" " } catch(e) {" " return false;"