Index: src/x64/macro-assembler-x64.cc |
diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc |
index 64f42f49ee21948aae4fea68997b043461127ced..32719384ad4b14222cb385bf489db2d1934920d5 100644 |
--- a/src/x64/macro-assembler-x64.cc |
+++ b/src/x64/macro-assembler-x64.cc |
@@ -2769,11 +2769,26 @@ void MacroAssembler::DebugBreak() { |
#endif // ENABLE_DEBUGGER_SUPPORT |
+void MacroAssembler::SetCallKind(Register dst, CallKind call_kind) { |
+ // This macro takes the dst register to make the code more readable |
+ // at the call sites. However, the dst register has to be rcx to |
+ // follow the calling convention which requires the call type to be |
+ // in rcx. |
+ ASSERT(dst.is(rcx)); |
+ if (call_kind == CALL_AS_FUNCTION) { |
+ LoadSmiConstant(dst, Smi::FromInt(1)); |
+ } else { |
+ LoadSmiConstant(dst, Smi::FromInt(0)); |
+ } |
+} |
+ |
+ |
void MacroAssembler::InvokeCode(Register code, |
const ParameterCount& expected, |
const ParameterCount& actual, |
InvokeFlag flag, |
- const CallWrapper& call_wrapper) { |
+ const CallWrapper& call_wrapper, |
+ CallKind call_kind) { |
Label done; |
InvokePrologue(expected, |
actual, |
@@ -2781,14 +2796,17 @@ void MacroAssembler::InvokeCode(Register code, |
code, |
&done, |
flag, |
+ Label::kNear, |
call_wrapper, |
- Label::kNear); |
+ call_kind); |
if (flag == CALL_FUNCTION) { |
call_wrapper.BeforeCall(CallSize(code)); |
+ SetCallKind(rcx, call_kind); |
call(code); |
call_wrapper.AfterCall(); |
} else { |
ASSERT(flag == JUMP_FUNCTION); |
+ SetCallKind(rcx, call_kind); |
jmp(code); |
} |
bind(&done); |
@@ -2800,7 +2818,8 @@ void MacroAssembler::InvokeCode(Handle<Code> code, |
const ParameterCount& actual, |
RelocInfo::Mode rmode, |
InvokeFlag flag, |
- const CallWrapper& call_wrapper) { |
+ const CallWrapper& call_wrapper, |
+ CallKind call_kind) { |
Label done; |
Register dummy = rax; |
InvokePrologue(expected, |
@@ -2809,14 +2828,17 @@ void MacroAssembler::InvokeCode(Handle<Code> code, |
dummy, |
&done, |
flag, |
+ Label::kNear, |
call_wrapper, |
- Label::kNear); |
+ call_kind); |
if (flag == CALL_FUNCTION) { |
call_wrapper.BeforeCall(CallSize(code)); |
+ SetCallKind(rcx, call_kind); |
Call(code, rmode); |
call_wrapper.AfterCall(); |
} else { |
ASSERT(flag == JUMP_FUNCTION); |
+ SetCallKind(rcx, call_kind); |
Jump(code, rmode); |
} |
bind(&done); |
@@ -2826,7 +2848,8 @@ void MacroAssembler::InvokeCode(Handle<Code> code, |
void MacroAssembler::InvokeFunction(Register function, |
const ParameterCount& actual, |
InvokeFlag flag, |
- const CallWrapper& call_wrapper) { |
+ const CallWrapper& call_wrapper, |
+ CallKind call_kind) { |
ASSERT(function.is(rdi)); |
movq(rdx, FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); |
movq(rsi, FieldOperand(function, JSFunction::kContextOffset)); |
@@ -2837,7 +2860,7 @@ void MacroAssembler::InvokeFunction(Register function, |
movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); |
ParameterCount expected(rbx); |
- InvokeCode(rdx, expected, actual, flag, call_wrapper); |
+ InvokeCode(rdx, expected, actual, flag, call_wrapper, call_kind); |
} |
@@ -2876,8 +2899,9 @@ void MacroAssembler::InvokePrologue(const ParameterCount& expected, |
Register code_register, |
Label* done, |
InvokeFlag flag, |
+ Label::Distance near_jump, |
const CallWrapper& call_wrapper, |
- Label::Distance near_jump) { |
+ CallKind call_kind) { |
bool definitely_matches = false; |
Label invoke; |
if (expected.is_immediate()) { |
@@ -2927,10 +2951,12 @@ void MacroAssembler::InvokePrologue(const ParameterCount& expected, |
if (flag == CALL_FUNCTION) { |
call_wrapper.BeforeCall(CallSize(adaptor)); |
+ SetCallKind(rcx, call_kind); |
Call(adaptor, RelocInfo::CODE_TARGET); |
call_wrapper.AfterCall(); |
jmp(done, near_jump); |
} else { |
+ SetCallKind(rcx, call_kind); |
Jump(adaptor, RelocInfo::CODE_TARGET); |
} |
bind(&invoke); |