Revision: 7097
Author: [email protected]
Date: Wed Mar 9 02:38:19 2011
Log: Add the possibility for a code stub to be non-movable
Non-moveable code-stube are allocated in large object space. They are only
required on ARM where the different C-entry stubs are required to never
move.
This gets rid of pre-computing these stubs and hope that they never move.
Also for crankshaft the C-entry stub which saved doubles is not generated
in the snapshot so it ends up being generated at runtime and potentially
move.
Review URL: http://codereview.chromium.org/6626072
http://code.google.com/p/v8/source/detail?r=7097
Modified:
/branches/bleeding_edge/src/arm/code-stubs-arm.cc
/branches/bleeding_edge/src/arm/code-stubs-arm.h
/branches/bleeding_edge/src/code-stubs.cc
/branches/bleeding_edge/src/code-stubs.h
/branches/bleeding_edge/src/factory.cc
/branches/bleeding_edge/src/factory.h
/branches/bleeding_edge/src/heap.cc
/branches/bleeding_edge/src/heap.h
/branches/bleeding_edge/src/ia32/code-stubs-ia32.cc
/branches/bleeding_edge/src/x64/code-stubs-x64.cc
=======================================
--- /branches/bleeding_edge/src/arm/code-stubs-arm.cc Tue Mar 8 02:29:40
2011
+++ /branches/bleeding_edge/src/arm/code-stubs-arm.cc Wed Mar 9 02:38:19
2011
@@ -4154,6 +4154,11 @@
__ bind(&call_runtime);
__ TailCallRuntime(Runtime::kMath_pow_cfunction, 2, 1);
}
+
+
+bool CEntryStub::NeedsImmovableCode() {
+ return true;
+}
void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) {
=======================================
--- /branches/bleeding_edge/src/arm/code-stubs-arm.h Wed Mar 2 06:40:38
2011
+++ /branches/bleeding_edge/src/arm/code-stubs-arm.h Wed Mar 9 02:38:19
2011
@@ -588,6 +588,9 @@
private:
Major MajorKey() { return RegExpCEntry; }
int MinorKey() { return 0; }
+
+ bool NeedsImmovableCode() { return true; }
+
const char* GetName() { return "RegExpCEntryStub"; }
};
@@ -607,6 +610,9 @@
private:
Major MajorKey() { return DirectCEntry; }
int MinorKey() { return 0; }
+
+ bool NeedsImmovableCode() { return true; }
+
const char* GetName() { return "DirectCEntryStub"; }
};
=======================================
--- /branches/bleeding_edge/src/code-stubs.cc Fri Feb 11 04:25:41 2011
+++ /branches/bleeding_edge/src/code-stubs.cc Wed Mar 9 02:38:19 2011
@@ -101,7 +101,8 @@
static_cast<Code::Kind>(GetCodeKind()),
InLoop(),
GetICState());
- Handle<Code> new_object = Factory::NewCode(desc, flags,
masm.CodeObject());
+ Handle<Code> new_object = Factory::NewCode(
+ desc, flags, masm.CodeObject(), NeedsImmovableCode());
RecordCodeGeneration(*new_object, &masm);
FinishCode(*new_object);
@@ -116,6 +117,7 @@
code = *new_object;
}
+ ASSERT(!NeedsImmovableCode() || Heap::lo_space()->Contains(code));
return Handle<Code>(code);
}
=======================================
--- /branches/bleeding_edge/src/code-stubs.h Tue Feb 15 05:53:51 2011
+++ /branches/bleeding_edge/src/code-stubs.h Wed Mar 9 02:38:19 2011
@@ -167,7 +167,11 @@
// Returns a name for logging/debugging purposes.
virtual const char* GetName() { return MajorName(MajorKey(), false); }
-#ifdef DEBUG
+ // Returns whether the code generated for this stub needs to be
allocated as
+ // a fixed (non-moveable) code object.
+ virtual bool NeedsImmovableCode() { return false; }
+
+ #ifdef DEBUG
virtual void Print() { PrintF("%s\n", GetName()); }
#endif
@@ -623,6 +627,8 @@
Major MajorKey() { return CEntry; }
int MinorKey();
+ bool NeedsImmovableCode();
+
const char* GetName() { return "CEntryStub"; }
};
=======================================
--- /branches/bleeding_edge/src/factory.cc Thu Feb 10 06:41:16 2011
+++ /branches/bleeding_edge/src/factory.cc Wed Mar 9 02:38:19 2011
@@ -605,8 +605,9 @@
Handle<Code> Factory::NewCode(const CodeDesc& desc,
Code::Flags flags,
- Handle<Object> self_ref) {
- CALL_HEAP_FUNCTION(Heap::CreateCode(desc, flags, self_ref), Code);
+ Handle<Object> self_ref,
+ bool immovable) {
+ CALL_HEAP_FUNCTION(Heap::CreateCode(desc, flags, self_ref, immovable),
Code);
}
=======================================
--- /branches/bleeding_edge/src/factory.h Thu Feb 10 04:02:36 2011
+++ /branches/bleeding_edge/src/factory.h Wed Mar 9 02:38:19 2011
@@ -252,7 +252,8 @@
static Handle<Code> NewCode(const CodeDesc& desc,
Code::Flags flags,
- Handle<Object> self_reference);
+ Handle<Object> self_reference,
+ bool immovable = false);
static Handle<Code> CopyCode(Handle<Code> code);
=======================================
--- /branches/bleeding_edge/src/heap.cc Wed Mar 2 02:16:47 2011
+++ /branches/bleeding_edge/src/heap.cc Wed Mar 9 02:38:19 2011
@@ -1906,20 +1906,6 @@
}
-void Heap::CreateCEntryStub() {
- CEntryStub stub(1);
- set_c_entry_code(*stub.GetCode());
-}
-
-
-#if V8_TARGET_ARCH_ARM && !V8_INTERPRETED_REGEXP
-void Heap::CreateRegExpCEntryStub() {
- RegExpCEntryStub stub;
- set_re_c_entry_code(*stub.GetCode());
-}
-#endif
-
-
void Heap::CreateJSEntryStub() {
JSEntryStub stub;
set_js_entry_code(*stub.GetCode());
@@ -1930,14 +1916,6 @@
JSConstructEntryStub stub;
set_js_construct_entry_code(*stub.GetCode());
}
-
-
-#if V8_TARGET_ARCH_ARM
-void Heap::CreateDirectCEntryStub() {
- DirectCEntryStub stub;
- set_direct_c_entry_code(*stub.GetCode());
-}
-#endif
void Heap::CreateFixedStubs() {
@@ -1947,22 +1925,15 @@
// stub cache for these stubs.
HandleScope scope;
// gcc-4.4 has problem generating correct code of following snippet:
- // { CEntryStub stub;
- // c_entry_code_ = *stub.GetCode();
+ // { JSEntryStub stub;
+ // js_entry_code_ = *stub.GetCode();
// }
- // { DebuggerStatementStub stub;
- // debugger_statement_code_ = *stub.GetCode();
+ // { JSConstructEntryStub stub;
+ // js_construct_entry_code_ = *stub.GetCode();
// }
// To workaround the problem, make separate functions without inlining.
- Heap::CreateCEntryStub();
Heap::CreateJSEntryStub();
Heap::CreateJSConstructEntryStub();
-#if V8_TARGET_ARCH_ARM && !V8_INTERPRETED_REGEXP
- Heap::CreateRegExpCEntryStub();
-#endif
-#if V8_TARGET_ARCH_ARM
- Heap::CreateDirectCEntryStub();
-#endif
}
@@ -2733,7 +2704,8 @@
MaybeObject* Heap::CreateCode(const CodeDesc& desc,
Code::Flags flags,
- Handle<Object> self_reference) {
+ Handle<Object> self_reference,
+ bool immovable) {
// Allocate ByteArray before the Code object, so that we do not risk
// leaving uninitialized Code object (and breaking the heap).
Object* reloc_info;
@@ -2741,12 +2713,14 @@
if (!maybe_reloc_info->ToObject(&reloc_info)) return maybe_reloc_info;
}
- // Compute size
+ // Compute size.
int body_size = RoundUp(desc.instr_size, kObjectAlignment);
int obj_size = Code::SizeFor(body_size);
ASSERT(IsAligned(static_cast<intptr_t>(obj_size), kCodeAlignment));
MaybeObject* maybe_result;
- if (obj_size > MaxObjectSizeInPagedSpace()) {
+ // Large code objects and code objects which should stay at a fixed
address
+ // are allocated in large object space.
+ if (obj_size > MaxObjectSizeInPagedSpace() || immovable) {
maybe_result = lo_space_->AllocateRawCode(obj_size);
} else {
maybe_result = code_space_->AllocateRaw(obj_size);
=======================================
--- /branches/bleeding_edge/src/heap.h Mon Mar 7 00:35:19 2011
+++ /branches/bleeding_edge/src/heap.h Wed Mar 9 02:38:19 2011
@@ -41,7 +41,7 @@
// Defines all the roots in Heap.
-#define
UNCONDITIONAL_STRONG_ROOT_LIST(V) \
+#define STRONG_ROOT_LIST(V) \
/* Put the byte array map early. We need it to be in place by the
time */ \
/* the deserializer hits the next page, since it wants to put a
byte */ \
/* array in the unused space at the end of the
page. */ \
@@ -114,26 +114,12 @@
V(NumberDictionary, non_monomorphic_cache,
NonMonomorphicCache) \
V(Code, js_entry_code,
JsEntryCode) \
V(Code, js_construct_entry_code,
JsConstructEntryCode) \
- V(Code, c_entry_code,
CEntryCode) \
V(FixedArray, natives_source_cache,
NativesSourceCache) \
V(Object, last_script_id,
LastScriptId) \
V(Script, empty_script,
EmptyScript) \
V(Smi, real_stack_limit,
RealStackLimit) \
V(StringDictionary, intrinsic_function_names,
IntrinsicFunctionNames) \
-#if V8_TARGET_ARCH_ARM && !V8_INTERPRETED_REGEXP
-#define
STRONG_ROOT_LIST(V) \
-
UNCONDITIONAL_STRONG_ROOT_LIST(V)
\
- V(Code, re_c_entry_code,
RegExpCEntryCode) \
- V(Code, direct_c_entry_code, DirectCEntryCode)
-#elif V8_TARGET_ARCH_ARM
-#define
STRONG_ROOT_LIST(V) \
-
UNCONDITIONAL_STRONG_ROOT_LIST(V)
\
- V(Code, direct_c_entry_code, DirectCEntryCode)
-#else
-#define STRONG_ROOT_LIST(V) UNCONDITIONAL_STRONG_ROOT_LIST(V)
-#endif
-
#define ROOT_LIST(V) \
STRONG_ROOT_LIST(V) \
V(SymbolTable, symbol_table, SymbolTable)
@@ -705,7 +691,8 @@
// Please note this function does not perform a garbage collection.
MUST_USE_RESULT static MaybeObject* CreateCode(const CodeDesc& desc,
Code::Flags flags,
- Handle<Object>
self_reference);
+ Handle<Object>
self_reference,
+ bool immovable = false);
MUST_USE_RESULT static MaybeObject* CopyCode(Code* code);
@@ -1327,13 +1314,10 @@
static bool CreateInitialMaps();
static bool CreateInitialObjects();
- // These five Create*EntryStub functions are here and forced to not be
inlined
+ // These two Create*EntryStub functions are here and forced to not be
inlined
// because of a gcc-4.4 bug that assigns wrong vtable entries.
- NO_INLINE(static void CreateCEntryStub());
NO_INLINE(static void CreateJSEntryStub());
NO_INLINE(static void CreateJSConstructEntryStub());
- NO_INLINE(static void CreateRegExpCEntryStub());
- NO_INLINE(static void CreateDirectCEntryStub());
static void CreateFixedStubs();
=======================================
--- /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc Mon Feb 28 06:57:14
2011
+++ /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc Wed Mar 9 02:38:19
2011
@@ -4645,6 +4645,11 @@
Handle<Code>
adaptor(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline));
__ jmp(adaptor, RelocInfo::CODE_TARGET);
}
+
+
+bool CEntryStub::NeedsImmovableCode() {
+ return false;
+}
void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) {
=======================================
--- /branches/bleeding_edge/src/x64/code-stubs-x64.cc Tue Mar 8 06:15:25
2011
+++ /branches/bleeding_edge/src/x64/code-stubs-x64.cc Wed Mar 9 02:38:19
2011
@@ -3297,6 +3297,11 @@
Handle<Code>
adaptor(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline));
__ Jump(adaptor, RelocInfo::CODE_TARGET);
}
+
+
+bool CEntryStub::NeedsImmovableCode() {
+ return false;
+}
void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) {
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev