Get rid of ContextualMode for call ICs.
authorverwaest@chromium.org <verwaest@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 14 Jan 2014 16:15:05 +0000 (16:15 +0000)
committerverwaest@chromium.org <verwaest@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 14 Jan 2014 16:15:05 +0000 (16:15 +0000)
BUG=
R=mvstanton@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18594 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

18 files changed:
src/arm/full-codegen-arm.cc
src/arm/lithium-codegen-arm.cc
src/ast.cc
src/ast.h
src/ia32/full-codegen-ia32.cc
src/ia32/lithium-codegen-ia32.cc
src/ic.cc
src/ic.h
src/stub-cache.cc
src/stub-cache.h
src/type-info.cc
src/type-info.h
src/typing.cc
src/x64/full-codegen-x64.cc
src/x64/lithium-codegen-x64.cc
test/cctest/test-heap.cc
test/mjsunit/regress/regress-2284.js
test/mjsunit/regress/regress-2286.js

index c23ab6cd04a5ec9566dc8b8144221022241190ab..68a8d70ecd27b63cb80b0ff62c0570e56b641994 100644 (file)
@@ -2614,8 +2614,7 @@ void FullCodeGenerator::EmitCallWithIC(Call* expr,
   // Record source position for debugger.
   SetSourcePosition(expr->position());
   // Call the IC initialization code.
-  Handle<Code> ic =
-      isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode);
+  Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arg_count);
   TypeFeedbackId ast_id = mode == CONTEXTUAL
       ? TypeFeedbackId::None()
       : expr->CallFeedbackId();
@@ -4155,10 +4154,8 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
   if (expr->is_jsruntime()) {
     // Call the JS runtime function.
     __ mov(r2, Operand(expr->name()));
-    ContextualMode mode = NOT_CONTEXTUAL;
-    Handle<Code> ic =
-        isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode);
-    CallIC(ic, mode, expr->CallRuntimeFeedbackId());
+    Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arg_count);
+    CallIC(ic, NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId());
     // Restore context register.
     __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
   } else {
index bf87123888827da4820d5f4e7e5b41a33f1f3de5..7483649889308e74f6bb87a0a6b44f9c541cdb3f 100644 (file)
@@ -3986,8 +3986,7 @@ void LCodeGen::DoCallNamed(LCallNamed* instr) {
   ASSERT(ToRegister(instr->result()).is(r0));
 
   int arity = instr->arity();
-  Handle<Code> ic =
-      isolate()->stub_cache()->ComputeCallInitialize(arity, NOT_CONTEXTUAL);
+  Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arity);
   __ mov(r2, Operand(instr->name()));
   CallCode(ic, RelocInfo::CODE_TARGET, instr, NEVER_INLINE_TARGET_ADDRESS);
 }
@@ -4014,8 +4013,7 @@ void LCodeGen::DoCallGlobal(LCallGlobal* instr) {
   ASSERT(ToRegister(instr->result()).is(r0));
 
   int arity = instr->arity();
-  Handle<Code> ic =
-      isolate()->stub_cache()->ComputeCallInitialize(arity, CONTEXTUAL);
+  Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arity);
   __ mov(r2, Operand(instr->name()));
   CallCode(ic, RelocInfo::CODE_TARGET, instr, NEVER_INLINE_TARGET_ADDRESS);
 }
index 042371f72894db8903bfb9ad5aef03e7e4dab26e..da86a1162d7bc726ab7c4ec5f8f94ff11ca7f26d 100644 (file)
@@ -696,8 +696,7 @@ Handle<JSObject> Call::GetPrototypeForPrimitiveCheck(
 }
 
 
-void Call::RecordTypeFeedback(TypeFeedbackOracle* oracle,
-                              ContextualMode contextual_mode) {
+void Call::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
   is_monomorphic_ = oracle->CallIsMonomorphic(CallFeedbackId());
   Property* property = expression()->AsProperty();
   if (property == NULL) {
@@ -712,7 +711,7 @@ void Call::RecordTypeFeedback(TypeFeedbackOracle* oracle,
     receiver_types_.Clear();
     if (check_type_ == RECEIVER_MAP_CHECK) {
       oracle->CallReceiverTypes(CallFeedbackId(),
-          name, arguments()->length(), contextual_mode, &receiver_types_);
+          name, arguments()->length(), &receiver_types_);
       is_monomorphic_ = is_monomorphic_ && receiver_types_.length() > 0;
     } else {
       holder_ = GetPrototypeForPrimitiveCheck(check_type_, oracle->isolate());
index ebd9fcf449ddc71b769f80286d300f0fcfdf2159..23f72df2ea87efee2cb00126e687bc682f677522 100644 (file)
--- a/src/ast.h
+++ b/src/ast.h
@@ -1737,8 +1737,7 @@ class Call V8_FINAL : public Expression {
 
   // Type feedback information.
   TypeFeedbackId CallFeedbackId() const { return reuse(id()); }
-  void RecordTypeFeedback(TypeFeedbackOracle* oracle,
-                          ContextualMode contextual_mode);
+  void RecordTypeFeedback(TypeFeedbackOracle* oracle);
   virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE {
     return &receiver_types_;
   }
index dc2c767a46faa4383dc5bdb266b6b3661ee115aa..7159d5c84b21532619907903b911e3aab1d83a60 100644 (file)
@@ -2569,7 +2569,7 @@ void FullCodeGenerator::EmitCallWithIC(Call* expr,
   // Record source position of the IC call.
   SetSourcePosition(expr->position());
   Handle<Code> ic =
-      isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode);
+      isolate()->stub_cache()->ComputeCallInitialize(arg_count);
   TypeFeedbackId ast_id = mode == CONTEXTUAL
       ? TypeFeedbackId::None()
       : expr->CallFeedbackId();
@@ -4146,10 +4146,8 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
   if (expr->is_jsruntime()) {
     // Call the JS runtime function via a call IC.
     __ Set(ecx, Immediate(expr->name()));
-    ContextualMode mode = NOT_CONTEXTUAL;
-    Handle<Code> ic =
-        isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode);
-    CallIC(ic, mode, expr->CallRuntimeFeedbackId());
+    Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arg_count);
+    CallIC(ic, NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId());
     // Restore context register.
     __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
   } else {
index a9ccfeaaf89e0c7b4cb2e3f387dce19423eff6e4..e2814959cd145957cfe532eb70c9bdc00846c1b9 100644 (file)
@@ -4229,8 +4229,7 @@ void LCodeGen::DoCallNamed(LCallNamed* instr) {
   ASSERT(ToRegister(instr->result()).is(eax));
 
   int arity = instr->arity();
-  Handle<Code> ic =
-      isolate()->stub_cache()->ComputeCallInitialize(arity, NOT_CONTEXTUAL);
+  Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arity);
   __ mov(ecx, instr->name());
   CallCode(ic, RelocInfo::CODE_TARGET, instr);
 }
@@ -4257,8 +4256,7 @@ void LCodeGen::DoCallGlobal(LCallGlobal* instr) {
   ASSERT(ToRegister(instr->result()).is(eax));
 
   int arity = instr->arity();
-  Handle<Code> ic =
-      isolate()->stub_cache()->ComputeCallInitialize(arity, CONTEXTUAL);
+  Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arity);
   __ mov(ecx, instr->name());
   CallCode(ic, RelocInfo::CODE_TARGET, instr);
 }
index 23697a9c98d1093b545a78e7660b823bccc9bd5c..807bde0577278db92c7589ca4ab099bff0bb4d36 100644 (file)
--- a/src/ic.cc
+++ b/src/ic.cc
@@ -489,9 +489,8 @@ void IC::Clear(Isolate* isolate, Address address) {
 
 void CallICBase::Clear(Address address, Code* target) {
   if (IsCleared(target)) return;
-  ContextualMode mode = IC::GetContextualMode(target->extra_ic_state());
   Code* code = target->GetIsolate()->stub_cache()->FindCallInitialize(
-      target->arguments_count(), mode, target->kind());
+      target->arguments_count(), target->kind());
   SetTargetAtAddress(address, code);
 }
 
index 9a42b75fc1894fe2026c88ba5baa29e7103c3b23..8a32a40447a80f55afd09a39f734a9ff6473b61a 100644 (file)
--- a/src/ic.h
+++ b/src/ic.h
@@ -124,7 +124,7 @@ class IC {
   // access to properties.
   bool IsUndeclaredGlobal(Handle<Object> receiver) {
     if (receiver->IsGlobalObject()) {
-      return IsContextual();
+      return IsCallStub() || IsContextual();
     } else {
       ASSERT(!IsContextual());
       return false;
@@ -140,10 +140,10 @@ class IC {
     return target()->is_store_stub() || target()->is_keyed_store_stub();
   }
 
+#endif
   bool IsCallStub() {
     return target()->is_call_stub() || target()->is_keyed_call_stub();
   }
-#endif
 
   // Determines which map must be used for keeping the code stub.
   // These methods should not be called with undefined or null.
@@ -323,10 +323,9 @@ enum StringStubFeedback {
 class CallICBase: public IC {
  public:
   // ExtraICState bits
-  class StringStubState: public BitField<StringStubFeedback, 1, 1> {};
-  static ExtraICState ComputeExtraICState(ContextualMode mode,
-                                          StringStubFeedback feedback) {
-    return Contextual::encode(mode) | StringStubState::encode(feedback);
+  class StringStubState: public BitField<StringStubFeedback, 0, 1> {};
+  static ExtraICState ComputeExtraICState(StringStubFeedback feedback) {
+    return StringStubState::encode(feedback);
   }
 
   // Returns a JSFunction or a Failure.
index 43375b050455e6e2e16a423ea009a848f6d79e22..38f1960594e400960903ab4588d6c27e971c5d56 100644 (file)
@@ -418,12 +418,9 @@ static void FillCache(Isolate* isolate, Handle<Code> code) {
 }
 
 
-Code* StubCache::FindCallInitialize(int argc,
-                                    ContextualMode mode,
-                                    Code::Kind kind) {
+Code* StubCache::FindCallInitialize(int argc, Code::Kind kind) {
   ExtraICState extra_state =
-      CallICBase::StringStubState::encode(DEFAULT_STRING_STUB) |
-      CallICBase::Contextual::encode(mode);
+      CallICBase::StringStubState::encode(DEFAULT_STRING_STUB);
   Code::Flags flags =
       Code::ComputeFlags(kind, UNINITIALIZED, extra_state, Code::NORMAL, argc);
   UnseededNumberDictionary* dictionary =
@@ -450,11 +447,9 @@ Code* StubCache::FindPreMonomorphicIC(Code::Kind kind, ExtraICState state) {
 }
 
 
-Handle<Code> StubCache::ComputeCallInitialize(int argc,
-                                              ContextualMode mode,
-                                              Code::Kind kind) {
+Handle<Code> StubCache::ComputeCallInitialize(int argc, Code::Kind kind) {
   ExtraICState extra_state =
-      CallICBase::ComputeExtraICState(mode, DEFAULT_STRING_STUB);
+      CallICBase::ComputeExtraICState(DEFAULT_STRING_STUB);
   Code::Flags flags =
       Code::ComputeFlags(kind, UNINITIALIZED, extra_state, Code::NORMAL, argc);
   Handle<UnseededNumberDictionary> cache =
@@ -469,13 +464,13 @@ Handle<Code> StubCache::ComputeCallInitialize(int argc,
 }
 
 
-Handle<Code> StubCache::ComputeCallInitialize(int argc, ContextualMode mode) {
-  return ComputeCallInitialize(argc, mode, Code::CALL_IC);
+Handle<Code> StubCache::ComputeCallInitialize(int argc) {
+  return ComputeCallInitialize(argc, Code::CALL_IC);
 }
 
 
 Handle<Code> StubCache::ComputeKeyedCallInitialize(int argc) {
-  return ComputeCallInitialize(argc, NOT_CONTEXTUAL, Code::KEYED_CALL_IC);
+  return ComputeCallInitialize(argc, Code::KEYED_CALL_IC);
 }
 
 
index 954c249e68108983d007e6724b497eb95ff77d44..1f3fa9320213c5d2b6b4463ce723287b251449d7 100644 (file)
@@ -138,7 +138,7 @@ class StubCache {
 
   // ---
 
-  Handle<Code> ComputeCallInitialize(int argc, ContextualMode mode);
+  Handle<Code> ComputeCallInitialize(int argc);
 
   Handle<Code> ComputeKeyedCallInitialize(int argc);
 
@@ -185,7 +185,7 @@ class StubCache {
                                     ExtraICState extra_ic_state);
 
   // Finds the Code object stored in the Heap::non_monomorphic_cache().
-  Code* FindCallInitialize(int argc, ContextualMode mode, Code::Kind kind);
+  Code* FindCallInitialize(int argc, Code::Kind kind);
   Code* FindPreMonomorphicIC(Code::Kind kind, ExtraICState extra_ic_state);
 
 #ifdef ENABLE_DEBUGGER_SUPPORT
@@ -269,9 +269,7 @@ class StubCache {
  private:
   explicit StubCache(Isolate* isolate);
 
-  Handle<Code> ComputeCallInitialize(int argc,
-                                     ContextualMode mode,
-                                     Code::Kind kind);
+  Handle<Code> ComputeCallInitialize(int argc, Code::Kind kind);
 
   // The stub cache has a primary and secondary level.  The two levels have
   // different hashing algorithms in order to avoid simultaneous collisions
index 883cdba331c337895dcaf93d3f40a0c5d5858f72..db2b71b6a39d05ac3f0b3557e1ea5fca7e015c6d 100644 (file)
@@ -178,14 +178,11 @@ KeyedAccessStoreMode TypeFeedbackOracle::GetStoreMode(
 void TypeFeedbackOracle::CallReceiverTypes(TypeFeedbackId id,
                                            Handle<String> name,
                                            int arity,
-                                           ContextualMode contextual_mode,
                                            SmallMapList* types) {
   // Note: Currently we do not take string extra ic data into account
   // here.
-  ExtraICState extra_ic_state =
-      CallIC::Contextual::encode(contextual_mode);
   Code::Flags flags = Code::ComputeMonomorphicFlags(
-      Code::CALL_IC, extra_ic_state, OWN_MAP, Code::NORMAL, arity);
+      Code::CALL_IC, kNoExtraICState, OWN_MAP, Code::NORMAL, arity);
   CollectReceiverTypes(id, name, flags, types);
 }
 
index 34270ab93be74cdc73a913cc0f7377d4dbd8b513..b5d7c599bc230638acab9e3d8b7ca85d990007de 100644 (file)
@@ -68,7 +68,6 @@ class TypeFeedbackOracle: public ZoneObject {
   void CallReceiverTypes(TypeFeedbackId id,
                          Handle<String> name,
                          int arity,
-                         ContextualMode contextual_mode,
                          SmallMapList* types);
   void PropertyReceiverTypes(TypeFeedbackId id,
                              Handle<String> name,
index 57b494d7663cb15a1290339a5e3e815b9350e7fa..b1fde82c13ef9caa2901ecb32df2afa842e2bd99 100644 (file)
@@ -530,11 +530,8 @@ void AstTyper::VisitProperty(Property* expr) {
 
 
 void AstTyper::VisitCall(Call* expr) {
-  Expression* callee = expr->expression();
-  Property* prop = callee->AsProperty();
-  ContextualMode contextual_mode = prop == NULL ? CONTEXTUAL : NOT_CONTEXTUAL;
   // Collect type feedback.
-  expr->RecordTypeFeedback(oracle(), contextual_mode);
+  expr->RecordTypeFeedback(oracle());
 
   RECURSE(Visit(expr->expression()));
   ZoneList<Expression*>* args = expr->arguments();
index df5aa398a0f87c17d46ea5b461b5fc7aaabd131a..e4d982893f82c58df87b2995ac24a8b133b64f0c 100644 (file)
@@ -2551,8 +2551,7 @@ void FullCodeGenerator::EmitCallWithIC(Call* expr,
   // Record source position for debugger.
   SetSourcePosition(expr->position());
   // Call the IC initialization code.
-  Handle<Code> ic =
-      isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode);
+  Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arg_count);
   TypeFeedbackId ast_id = mode == CONTEXTUAL
       ? TypeFeedbackId::None()
       : expr->CallFeedbackId();
@@ -4150,10 +4149,8 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
   if (expr->is_jsruntime()) {
     // Call the JS runtime function using a call IC.
     __ Move(rcx, expr->name());
-    ContextualMode mode = NOT_CONTEXTUAL;
-    Handle<Code> ic =
-        isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode);
-    CallIC(ic, mode, expr->CallRuntimeFeedbackId());
+    Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arg_count);
+    CallIC(ic, NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId());
     // Restore context register.
     __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
   } else {
index af5bf45a3f9701cb985a8671801341fd8e6673b5..c3fbba4e417488accef545c0749f58ca3947f905 100644 (file)
@@ -3801,8 +3801,7 @@ void LCodeGen::DoCallNamed(LCallNamed* instr) {
   ASSERT(ToRegister(instr->result()).is(rax));
 
   int arity = instr->arity();
-  Handle<Code> ic =
-      isolate()->stub_cache()->ComputeCallInitialize(arity, NOT_CONTEXTUAL);
+  Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arity);
   __ Move(rcx, instr->name());
   CallCode(ic, RelocInfo::CODE_TARGET, instr);
 }
@@ -3828,8 +3827,7 @@ void LCodeGen::DoCallGlobal(LCallGlobal* instr) {
   ASSERT(ToRegister(instr->context()).is(rsi));
   ASSERT(ToRegister(instr->result()).is(rax));
   int arity = instr->arity();
-  Handle<Code> ic =
-      isolate()->stub_cache()->ComputeCallInitialize(arity, CONTEXTUAL);
+  Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arity);
   __ Move(rcx, instr->name());
   CallCode(ic, RelocInfo::CODE_TARGET, instr);
 }
index 493cbd3e2f23f307f29233d355a72098ea4d284e..fa7ef48ebdbf0882a4ed0adf5de6ab1348d7626a 100644 (file)
@@ -3090,7 +3090,7 @@ TEST(Regression144230) {
     HandleScope inner_scope(isolate);
     AlwaysAllocateScope always_allocate;
     SimulateFullSpace(heap->code_space());
-    isolate->stub_cache()->ComputeCallInitialize(9, NOT_CONTEXTUAL);
+    isolate->stub_cache()->ComputeCallInitialize(9);
   }
 
   // Second compile a CallIC and execute it once so that it gets patched to
index 561401998ad84e75e8baa2fd85b9a10bf8211535..24bf58e2db677db9c13f68090bb5555c2cd9a90e 100644 (file)
@@ -27,6 +27,6 @@
 
 // Flags: --allow-natives-syntax
 
-assertThrows("%foobar();", TypeError);
-assertThrows("%constructor();", TypeError);
-assertThrows("%constructor(23);", TypeError);
+assertThrows("%foobar();", Error);
+assertThrows("%constructor();", Error);
+assertThrows("%constructor(23);", Error);
index 372451ec44ee067789fbf156c782bec6e5b36408..0264900442809ad9ac6c0612a3ac07fdf5c50531 100644 (file)
@@ -28,5 +28,5 @@
 // Flags: --allow-natives-syntax
 
 assertThrows("f()", ReferenceError);
-assertThrows("%f()", TypeError);
+assertThrows("%f()", Error);
 assertThrows("%_f()", SyntaxError);