}
+bool CEntryStub::NeedsImmovableCode() {
+ return true;
+}
+
+
void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) {
__ Throw(r0);
}
private:
Major MajorKey() { return RegExpCEntry; }
int MinorKey() { return 0; }
+
+ bool NeedsImmovableCode() { return true; }
+
const char* GetName() { return "RegExpCEntryStub"; }
};
private:
Major MajorKey() { return DirectCEntry; }
int MinorKey() { return 0; }
+
+ bool NeedsImmovableCode() { return true; }
+
const char* GetName() { return "DirectCEntryStub"; }
};
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);
code = *new_object;
}
+ ASSERT(!NeedsImmovableCode() || Heap::lo_space()->Contains(code));
return Handle<Code>(code);
}
// 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
Major MajorKey() { return CEntry; }
int MinorKey();
+ bool NeedsImmovableCode();
+
const char* GetName() { return "CEntryStub"; }
};
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);
}
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);
}
-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());
}
-#if V8_TARGET_ARCH_ARM
-void Heap::CreateDirectCEntryStub() {
- DirectCEntryStub stub;
- set_direct_c_entry_code(*stub.GetCode());
-}
-#endif
-
-
void Heap::CreateFixedStubs() {
// Here we create roots for fixed stubs. They are needed at GC
// for cooking and uncooking (check out frames.cc).
// 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
}
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;
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);
// 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. */ \
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)
// 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);
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();
}
+bool CEntryStub::NeedsImmovableCode() {
+ return false;
+}
+
+
void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) {
__ Throw(eax);
}
}
+bool CEntryStub::NeedsImmovableCode() {
+ return false;
+}
+
+
void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) {
// Throw exception in eax.
__ Throw(rax);