Revision: 20577
Author:   [email protected]
Date:     Tue Apr  8 12:28:28 2014 UTC
Log:      Use correct call size for PredictableCodeSizeScopes.

If out-of-line constant pool is enabled, then calls can be 3 instructions
rather than 2. Fix the hard-coded PredictableCodeSizeScopes values with values
based on CallSize instead.

[email protected]

Review URL: https://codereview.chromium.org/226503003
http://code.google.com/p/v8/source/detail?r=20577

Modified:
 /branches/bleeding_edge/src/arm/code-stubs-arm.cc
 /branches/bleeding_edge/src/arm/full-codegen-arm.cc
 /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc
 /branches/bleeding_edge/src/arm/lithium-codegen-arm.h
 /branches/bleeding_edge/src/arm/macro-assembler-arm.cc
 /branches/bleeding_edge/src/arm/macro-assembler-arm.h

=======================================
--- /branches/bleeding_edge/src/arm/code-stubs-arm.cc Fri Apr 4 16:18:59 2014 UTC +++ /branches/bleeding_edge/src/arm/code-stubs-arm.cc Tue Apr 8 12:28:28 2014 UTC
@@ -4951,8 +4951,9 @@

 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) {
   if (masm->isolate()->function_entry_hook() != NULL) {
-    PredictableCodeSizeScope predictable(masm, 4 * Assembler::kInstrSize);
     ProfileEntryHookStub stub;
+    int code_size = masm->CallStubSize(&stub) + 2 * Assembler::kInstrSize;
+    PredictableCodeSizeScope predictable(masm, code_size);
     __ push(lr);
     __ CallStub(&stub);
     __ pop(lr);
=======================================
--- /branches/bleeding_edge/src/arm/full-codegen-arm.cc Fri Apr 4 16:18:59 2014 UTC +++ /branches/bleeding_edge/src/arm/full-codegen-arm.cc Tue Apr 8 12:28:28 2014 UTC
@@ -128,8 +128,10 @@
   __ LoadRoot(stack_limit_scratch, index);
   __ cmp(scratch, Operand(stack_limit_scratch));
   __ b(hs, &ok);
-  PredictableCodeSizeScope predictable(masm_, 2 * Assembler::kInstrSize);
-  __ Call(isolate->builtins()->StackCheck(), RelocInfo::CODE_TARGET);
+  Handle<Code> stack_check = isolate->builtins()->StackCheck();
+  PredictableCodeSizeScope predictable(masm_,
+      masm_->CallSize(stack_check, RelocInfo::CODE_TARGET));
+  __ Call(stack_check, RelocInfo::CODE_TARGET);
   __ bind(&ok);
 }

=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Mon Apr 7 12:08:40 2014 UTC +++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Tue Apr 8 12:28:28 2014 UTC
@@ -712,6 +712,16 @@
     UNREACHABLE();
   }
 }
+
+
+int LCodeGen::CallCodeSize(Handle<Code> code, RelocInfo::Mode mode) {
+  int size = masm()->CallSize(code, mode);
+  if (code->kind() == Code::BINARY_OP_IC ||
+      code->kind() == Code::COMPARE_IC) {
+ size += Assembler::kInstrSize; // extra nop() added in CallCodeGeneric.
+  }
+  return size;
+}


 void LCodeGen::CallCode(Handle<Code> code,
@@ -5672,12 +5682,12 @@
     __ LoadRoot(ip, Heap::kStackLimitRootIndex);
     __ cmp(sp, Operand(ip));
     __ b(hs, &done);
-    PredictableCodeSizeScope predictable(masm_, 2 * Assembler::kInstrSize);
+    Handle<Code> stack_check = isolate()->builtins()->StackCheck();
+    PredictableCodeSizeScope predictable(masm(),
+        CallCodeSize(stack_check, RelocInfo::CODE_TARGET));
     ASSERT(instr->context()->IsRegister());
     ASSERT(ToRegister(instr->context()).is(cp));
-    CallCode(isolate()->builtins()->StackCheck(),
-              RelocInfo::CODE_TARGET,
-              instr);
+    CallCode(stack_check, RelocInfo::CODE_TARGET, instr);
     __ bind(&done);
   } else {
     ASSERT(instr->hydrogen()->is_backwards_branch());
=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.h Mon Mar 31 14:21:04 2014 UTC +++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.h Tue Apr 8 12:28:28 2014 UTC
@@ -209,6 +209,8 @@
     RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS
   };

+  int CallCodeSize(Handle<Code> code, RelocInfo::Mode mode);
+
   void CallCode(
       Handle<Code> code,
       RelocInfo::Mode mode,
=======================================
--- /branches/bleeding_edge/src/arm/macro-assembler-arm.cc Tue Apr 1 10:49:44 2014 UTC +++ /branches/bleeding_edge/src/arm/macro-assembler-arm.cc Tue Apr 8 12:28:28 2014 UTC
@@ -105,6 +105,13 @@
   }
   return size;
 }
+
+
+int MacroAssembler::CallStubSize(
+    CodeStub* stub, TypeFeedbackId ast_id, Condition cond) {
+  return CallSize(
+      stub->GetCode(isolate()), RelocInfo::CODE_TARGET, ast_id, cond);
+}


 int MacroAssembler::CallSizeNotPredictableCodeSize(
=======================================
--- /branches/bleeding_edge/src/arm/macro-assembler-arm.h Tue Apr 1 10:49:44 2014 UTC +++ /branches/bleeding_edge/src/arm/macro-assembler-arm.h Tue Apr 8 12:28:28 2014 UTC
@@ -102,6 +102,9 @@
   static int CallSize(Register target, Condition cond = al);
   void Call(Register target, Condition cond = al);
   int CallSize(Address target, RelocInfo::Mode rmode, Condition cond = al);
+  int CallStubSize(CodeStub* stub,
+                   TypeFeedbackId ast_id = TypeFeedbackId::None(),
+                   Condition cond = al);
   static int CallSizeNotPredictableCodeSize(Address target,
                                             RelocInfo::Mode rmode,
                                             Condition cond = al);

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to