}
-int CEntryStub::MinorKey() {
- ASSERT(result_size_ <= 2);
- // Result returned in r0 or r0+r1 by default.
- return 0;
-}
-
-
void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) {
// r0 holds the exception.
Label* throw_normal_exception,
Label* throw_termination_exception,
Label* throw_out_of_memory_exception,
- ExitFrame::Mode mode,
bool do_gc,
bool always_allocate) {
// r0: result parameter for PerformGC, if any
// r0:r1: result
// sp: stack pointer
// fp: frame pointer
- __ LeaveExitFrame(mode);
+ __ LeaveExitFrame(mode_);
// check if we should retry or throw exception
Label retry;
}
-void CEntryStub::GenerateBody(MacroAssembler* masm, bool is_debug_break) {
+void CEntryStub::Generate(MacroAssembler* masm) {
// Called from JavaScript; parameters are on stack as if calling JS function
// r0: number of arguments including receiver
// r1: pointer to builtin function
// sp: stack pointer (restored as callee's sp after C call)
// cp: current context (C callee-saved)
+ // Result returned in r0 or r0+r1 by default.
+
// NOTE: Invocations of builtins may return failure objects
// instead of a proper result. The builtin entry handles
// this by performing a garbage collection and retrying the
// builtin once.
- ExitFrame::Mode mode = is_debug_break
- ? ExitFrame::MODE_DEBUG
- : ExitFrame::MODE_NORMAL;
-
// Enter the exit frame that transitions from JavaScript to C++.
- __ EnterExitFrame(mode);
+ __ EnterExitFrame(mode_);
// r4: number of arguments (C callee-saved)
// r5: pointer to builtin function (C callee-saved)
&throw_normal_exception,
&throw_termination_exception,
&throw_out_of_memory_exception,
- mode,
false,
false);
&throw_normal_exception,
&throw_termination_exception,
&throw_out_of_memory_exception,
- mode,
true,
false);
&throw_normal_exception,
&throw_termination_exception,
&throw_out_of_memory_exception,
- mode,
true,
true);
__ mov(r0, Operand(0)); // no arguments
__ mov(r1, Operand(ExternalReference::debug_break()));
- CEntryStub ceb(1);
+ CEntryStub ceb(1, ExitFrame::MODE_DEBUG);
__ CallStub(&ceb);
// Restore the register values containing object pointers from the expression
}
+int CEntryStub::MinorKey() {
+ ASSERT(result_size_ <= 2);
+#ifdef _WIN64
+ const indirect_result = result_size_ > 1;
+#else
+ const bool indirect_result = false;
+#endif
+
+ return ExitFrameModeBits::encode(mode_)
+ | IndirectResultBits::encode(indirect_result > 1);
+}
+
+
bool ApiGetterEntryStub::GetCustomCache(Code** code_out) {
Object* cache = info()->load_stub_cache();
if (cache->IsUndefined()) {
class CEntryStub : public CodeStub {
public:
- explicit CEntryStub(int result_size) : result_size_(result_size) { }
+ explicit CEntryStub(int result_size,
+ ExitFrame::Mode mode = ExitFrame::MODE_NORMAL)
+ : result_size_(result_size), mode_(mode) { }
- void Generate(MacroAssembler* masm) { GenerateBody(masm, false); }
+ void Generate(MacroAssembler* masm);
- protected:
- void GenerateBody(MacroAssembler* masm, bool is_debug_break);
+ private:
void GenerateCore(MacroAssembler* masm,
Label* throw_normal_exception,
Label* throw_termination_exception,
Label* throw_out_of_memory_exception,
- ExitFrame::Mode mode,
bool do_gc,
bool always_allocate_scope);
void GenerateThrowTOS(MacroAssembler* masm);
void GenerateThrowUncatchable(MacroAssembler* masm,
UncatchableExceptionType type);
- private:
+
// Number of pointers/values returned.
- int result_size_;
+ int const result_size_;
+ ExitFrame::Mode const mode_;
+
+ // Minor key encoding
+ class ExitFrameModeBits: public BitField<ExitFrame::Mode, 0, 1> {};
+ class IndirectResultBits: public BitField<bool, 1, 1> {};
Major MajorKey() { return CEntry; }
// Minor key must differ if different result_size_ values means different
};
-// Mark the debugger statemet to be recognized bu debugger (by the MajorKey)
+// Mark the debugger statemet to be recognized by debugger (by the MajorKey)
class DebugerStatementStub : public CodeStub {
public:
DebugerStatementStub() { }
Code* ExitFrame::code() const {
Object* code = code_slot();
if (code->IsSmi()) {
- return Heap::c_entry_debug_break_code();
+ return Heap::debugger_statement_code();
} else {
return Code::cast(code);
}
void Heap::CreateCEntryDebugBreakStub() {
DebugerStatementStub stub;
- set_c_entry_debug_break_code(*stub.GetCode());
+ set_debugger_statement_code(*stub.GetCode());
}
// c_entry_code_ = *stub.GetCode();
// }
// { DebugerStatementStub stub;
- // c_entry_debug_break_code_ = *stub.GetCode();
+ // debugger_statement_code_ = *stub.GetCode();
// }
// To workaround the problem, make separate functions without inlining.
Heap::CreateCEntryStub();
V(Code, js_entry_code, JsEntryCode) \
V(Code, js_construct_entry_code, JsConstructEntryCode) \
V(Code, c_entry_code, CEntryCode) \
- V(Code, c_entry_debug_break_code, CEntryDebugBreakCode) \
+ V(Code, debugger_statement_code, DebuggerStatementCode) \
V(FixedArray, number_string_cache, NumberStringCache) \
V(FixedArray, single_character_string_cache, SingleCharacterStringCache) \
V(FixedArray, natives_source_cache, NativesSourceCache) \
}
-int CEntryStub::MinorKey() {
- ASSERT(result_size_ <= 2);
- // Result returned in eax, or eax+edx if result_size_ is 2.
- return 0;
-}
-
-
void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) {
// eax holds the exception.
Label* throw_normal_exception,
Label* throw_termination_exception,
Label* throw_out_of_memory_exception,
- ExitFrame::Mode mode,
bool do_gc,
bool always_allocate_scope) {
// eax: result parameter for PerformGC, if any
// edi: number of arguments including receiver (C callee-saved)
// esi: pointer to the first argument (C callee-saved)
+ // Result returned in eax, or eax+edx if result_size_ is 2.
+
if (do_gc) {
__ mov(Operand(esp, 0 * kPointerSize), eax); // Result.
__ call(FUNCTION_ADDR(Runtime::PerformGC), RelocInfo::RUNTIME_ENTRY);
__ j(zero, &failure_returned, not_taken);
// Exit the JavaScript to C++ exit frame.
- __ LeaveExitFrame(mode);
+ __ LeaveExitFrame(mode_);
__ ret(0);
// Handling of failure.
}
-void CEntryStub::GenerateBody(MacroAssembler* masm, bool is_debug_break) {
+void CEntryStub::Generate(MacroAssembler* masm) {
// eax: number of arguments including receiver
// ebx: pointer to C function (C callee-saved)
// ebp: frame pointer (restored after C call)
// of a proper result. The builtin entry handles this by performing
// a garbage collection and retrying the builtin (twice).
- ExitFrame::Mode mode = is_debug_break
- ? ExitFrame::MODE_DEBUG
- : ExitFrame::MODE_NORMAL;
-
// Enter the exit frame that transitions from JavaScript to C++.
- __ EnterExitFrame(mode);
+ __ EnterExitFrame(mode_);
// eax: result parameter for PerformGC, if any (setup below)
// ebx: pointer to builtin function (C callee-saved)
&throw_normal_exception,
&throw_termination_exception,
&throw_out_of_memory_exception,
- mode,
false,
false);
&throw_normal_exception,
&throw_termination_exception,
&throw_out_of_memory_exception,
- mode,
true,
false);
&throw_normal_exception,
&throw_termination_exception,
&throw_out_of_memory_exception,
- mode,
true,
true);
__ Set(eax, Immediate(0)); // no arguments
__ mov(ebx, Immediate(ExternalReference::debug_break()));
- CEntryStub ceb(1);
+ CEntryStub ceb(1, ExitFrame::MODE_DEBUG);
__ CallStub(&ceb);
// Restore the register values containing object pointers from the expression
}
-int CEntryStub::MinorKey() {
- ASSERT(result_size_ <= 2);
-#ifdef _WIN64
- // Simple results returned in rax (using default code).
- // Complex results must be written to address passed as first argument.
- return (result_size_ < 2) ? 0 : 1;
-#else
- // Single results returned in rax (both AMD64 and Win64 calling conventions)
- // and a struct of two pointers in rax+rdx (AMD64 calling convention only)
- // by default.
- return 0;
-#endif
-}
-
-
void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) {
// Check that stack should contain next handler, frame pointer, state and
// return address in that order.
Label* throw_normal_exception,
Label* throw_termination_exception,
Label* throw_out_of_memory_exception,
- ExitFrame::Mode mode,
bool do_gc,
bool always_allocate_scope) {
// rax: result parameter for PerformGC, if any.
// This pointer is reused in LeaveExitFrame(), so it is stored in a
// callee-saved register.
+ // Simple results returned in rax (both AMD64 and Win64 calling conventions).
+ // Complex results must be written to address passed as first argument.
+ // AMD64 calling convention: a struct of two pointers in rax+rdx
+
if (do_gc) {
// Pass failure code returned from last attempt as first argument to GC.
#ifdef _WIN64
__ j(zero, &failure_returned);
// Exit the JavaScript to C++ exit frame.
- __ LeaveExitFrame(mode, result_size_);
+ __ LeaveExitFrame(mode_, result_size_);
__ ret(0);
// Handling of failure.
}
-void CEntryStub::GenerateBody(MacroAssembler* masm, bool is_debug_break) {
+void CEntryStub::Generate(MacroAssembler* masm) {
// rax: number of arguments including receiver
// rbx: pointer to C function (C callee-saved)
// rbp: frame pointer of calling JS frame (restored after C call)
// this by performing a garbage collection and retrying the
// builtin once.
- ExitFrame::Mode mode = is_debug_break ?
- ExitFrame::MODE_DEBUG :
- ExitFrame::MODE_NORMAL;
-
// Enter the exit frame that transitions from JavaScript to C++.
- __ EnterExitFrame(mode, result_size_);
+ __ EnterExitFrame(mode_, result_size_);
// rax: Holds the context at this point, but should not be used.
// On entry to code generated by GenerateCore, it must hold
&throw_normal_exception,
&throw_termination_exception,
&throw_out_of_memory_exception,
- mode,
false,
false);
&throw_normal_exception,
&throw_termination_exception,
&throw_out_of_memory_exception,
- mode,
true,
false);
&throw_normal_exception,
&throw_termination_exception,
&throw_out_of_memory_exception,
- mode,
true,
true);
__ xor_(rax, rax); // No arguments (argc == 0).
__ movq(rbx, ExternalReference::debug_break());
- CEntryStub ceb(1);
+ CEntryStub ceb(1, ExitFrame::MODE_DEBUG);
__ CallStub(&ceb);
// Restore the register values containing object pointers from the expression