Commit d634e65f authored by ishell's avatar ishell Committed by Commit bot

[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}
parent 01766cd8
...@@ -19,7 +19,9 @@ class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> { ...@@ -19,7 +19,9 @@ class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> {
yield_count_(0), yield_count_(0),
properties_(zone), properties_(zone),
slot_cache_(zone), slot_cache_(zone),
slot_cache_inside_typeof_(zone),
dont_optimize_reason_(kNoReason), dont_optimize_reason_(kNoReason),
typeof_mode_(NOT_INSIDE_TYPEOF),
catch_prediction_(HandlerTable::UNCAUGHT) { catch_prediction_(HandlerTable::UNCAUGHT) {
InitializeAstVisitor(isolate); InitializeAstVisitor(isolate);
} }
...@@ -62,7 +64,9 @@ class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> { ...@@ -62,7 +64,9 @@ class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> {
template <typename Node> template <typename Node>
void ReserveFeedbackSlots(Node* node) { void ReserveFeedbackSlots(Node* node) {
node->AssignFeedbackVectorSlots(isolate_, properties_.get_spec(), 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_; } BailoutReason dont_optimize_reason() const { return dont_optimize_reason_; }
...@@ -74,7 +78,9 @@ class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> { ...@@ -74,7 +78,9 @@ class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> {
AstProperties properties_; AstProperties properties_;
// The slot cache allows us to reuse certain feedback vector slots. // The slot cache allows us to reuse certain feedback vector slots.
FeedbackVectorSlotCache slot_cache_; FeedbackVectorSlotCache slot_cache_;
FeedbackVectorSlotCache slot_cache_inside_typeof_;
BailoutReason dont_optimize_reason_; BailoutReason dont_optimize_reason_;
TypeofMode typeof_mode_;
HandlerTable::CatchPrediction catch_prediction_; HandlerTable::CatchPrediction catch_prediction_;
DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
...@@ -216,9 +222,13 @@ void AstNumberingVisitor::VisitThrow(Throw* node) { ...@@ -216,9 +222,13 @@ void AstNumberingVisitor::VisitThrow(Throw* node) {
void AstNumberingVisitor::VisitUnaryOperation(UnaryOperation* node) { void AstNumberingVisitor::VisitUnaryOperation(UnaryOperation* node) {
Token::Value op = node->op();
TypeofMode old_typeof_mode = typeof_mode_;
IncrementNodeCount(); IncrementNodeCount();
if (op == Token::TYPEOF) typeof_mode_ = INSIDE_TYPEOF;
node->set_base_id(ReserveIdRange(UnaryOperation::num_ids())); node->set_base_id(ReserveIdRange(UnaryOperation::num_ids()));
Visit(node->expression()); Visit(node->expression());
typeof_mode_ = old_typeof_mode;
} }
......
...@@ -873,7 +873,21 @@ THREADED_TEST(InterceptorLoadGlobalICGlobalWithInterceptor) { ...@@ -873,7 +873,21 @@ THREADED_TEST(InterceptorLoadGlobalICGlobalWithInterceptor) {
v8::Local<Value> value = CompileRun( v8::Local<Value> value = CompileRun(
"var f = function() { " "var f = function() { "
" try {" " 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;" " return false;"
" } catch(e) {" " } catch(e) {"
" return true;" " return true;"
...@@ -888,7 +902,7 @@ THREADED_TEST(InterceptorLoadGlobalICGlobalWithInterceptor) { ...@@ -888,7 +902,7 @@ THREADED_TEST(InterceptorLoadGlobalICGlobalWithInterceptor) {
value = CompileRun( value = CompileRun(
"var f = function() { " "var f = function() { "
" try {" " try {"
" typeof(x);" " typeof(x3);"
" return true;" " return true;"
" } catch(e) {" " } catch(e) {"
" return false;" " return false;"
......
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