Commit 198e09de authored by jgruber's avatar jgruber Committed by Commit bot

[builtins] Use BUILTIN frame in DatePrototype_GetField

Construct a BUILTIN frame before throwing an exception from runtime.

R=bmeurer@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2078443002
Cr-Commit-Position: refs/heads/master@{#37053}
parent fe8f31e8
......@@ -1734,6 +1734,9 @@ void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) {
void Builtins::Generate_DatePrototype_GetField(MacroAssembler* masm,
int field_index) {
// ----------- S t a t e -------------
// -- r0 : number of arguments
// -- r1 : function
// -- cp : context
// -- lr : return address
// -- sp[0] : receiver
// -----------------------------------
......@@ -1743,7 +1746,7 @@ void Builtins::Generate_DatePrototype_GetField(MacroAssembler* masm,
{
__ Pop(r0);
__ JumpIfSmi(r0, &receiver_not_date);
__ CompareObjectType(r0, r1, r2, JS_DATE_TYPE);
__ CompareObjectType(r0, r2, r3, JS_DATE_TYPE);
__ b(ne, &receiver_not_date);
}
......@@ -1773,7 +1776,14 @@ void Builtins::Generate_DatePrototype_GetField(MacroAssembler* masm,
// 3. Raise a TypeError if the receiver is not a date.
__ bind(&receiver_not_date);
__ TailCallRuntime(Runtime::kThrowNotDateError);
{
FrameScope scope(masm, StackFrame::MANUAL);
__ Push(r0, lr, fp);
__ Move(fp, sp);
__ Push(cp, r1);
__ Push(Smi::FromInt(0));
__ CallRuntime(Runtime::kThrowNotDateError);
}
}
// static
......
......@@ -1746,6 +1746,9 @@ void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) {
void Builtins::Generate_DatePrototype_GetField(MacroAssembler* masm,
int field_index) {
// ----------- S t a t e -------------
// -- x0 : number of arguments
// -- x1 : function
// -- cp : context
// -- lr : return address
// -- jssp[0] : receiver
// -----------------------------------
......@@ -1756,7 +1759,7 @@ void Builtins::Generate_DatePrototype_GetField(MacroAssembler* masm,
{
__ Pop(x0);
__ JumpIfSmi(x0, &receiver_not_date);
__ JumpIfNotObjectType(x0, x1, x2, JS_DATE_TYPE, &receiver_not_date);
__ JumpIfNotObjectType(x0, x2, x3, JS_DATE_TYPE, &receiver_not_date);
}
// 2. Load the specified date field, falling back to the runtime as necessary.
......@@ -1784,7 +1787,14 @@ void Builtins::Generate_DatePrototype_GetField(MacroAssembler* masm,
// 3. Raise a TypeError if the receiver is not a date.
__ Bind(&receiver_not_date);
__ TailCallRuntime(Runtime::kThrowNotDateError);
{
FrameScope scope(masm, StackFrame::MANUAL);
__ Push(x0, lr, fp);
__ Move(fp, jssp);
__ Push(cp, x1);
__ Push(Smi::FromInt(0));
__ CallRuntime(Runtime::kThrowNotDateError);
}
}
// static
......
......@@ -1193,6 +1193,9 @@ void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) {
void Builtins::Generate_DatePrototype_GetField(MacroAssembler* masm,
int field_index) {
// ----------- S t a t e -------------
// -- eax : number of arguments
// -- edi : function
// -- esi : context
// -- esp[0] : return address
// -- esp[4] : receiver
// -----------------------------------
......@@ -1235,7 +1238,11 @@ void Builtins::Generate_DatePrototype_GetField(MacroAssembler* masm,
__ bind(&receiver_not_date);
{
FrameScope scope(masm, StackFrame::MANUAL);
__ EnterFrame(StackFrame::INTERNAL);
__ Push(ebp);
__ Move(ebp, esp);
__ Push(esi);
__ Push(edi);
__ Push(Immediate(0));
__ CallRuntime(Runtime::kThrowNotDateError);
}
}
......
......@@ -1733,6 +1733,9 @@ void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) {
void Builtins::Generate_DatePrototype_GetField(MacroAssembler* masm,
int field_index) {
// ----------- S t a t e -------------
// -- a0 : number of arguments
// -- a1 : function
// -- cp : context
// -- sp[0] : receiver
// -----------------------------------
......@@ -1772,7 +1775,14 @@ void Builtins::Generate_DatePrototype_GetField(MacroAssembler* masm,
// 3. Raise a TypeError if the receiver is not a date.
__ bind(&receiver_not_date);
__ TailCallRuntime(Runtime::kThrowNotDateError);
{
FrameScope scope(masm, StackFrame::MANUAL);
__ Push(a0, ra, fp);
__ Move(fp, sp);
__ Push(cp, a1);
__ Push(Smi::FromInt(0));
__ CallRuntime(Runtime::kThrowNotDateError);
}
}
// static
......
......@@ -1720,6 +1720,9 @@ void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) {
void Builtins::Generate_DatePrototype_GetField(MacroAssembler* masm,
int field_index) {
// ----------- S t a t e -------------
// -- a0 : number of arguments
// -- a1 : function
// -- cp : context
// -- sp[0] : receiver
// -----------------------------------
......@@ -1759,7 +1762,14 @@ void Builtins::Generate_DatePrototype_GetField(MacroAssembler* masm,
// 3. Raise a TypeError if the receiver is not a date.
__ bind(&receiver_not_date);
__ TailCallRuntime(Runtime::kThrowNotDateError);
{
FrameScope scope(masm, StackFrame::MANUAL);
__ Push(a0, ra, fp);
__ Move(fp, sp);
__ Push(cp, a1);
__ Push(Smi::FromInt(0));
__ CallRuntime(Runtime::kThrowNotDateError);
}
}
// static
......
......@@ -1245,6 +1245,9 @@ void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) {
void Builtins::Generate_DatePrototype_GetField(MacroAssembler* masm,
int field_index) {
// ----------- S t a t e -------------
// -- rax : number of arguments
// -- rdi : function
// -- rsi : context
// -- rsp[0] : return address
// -- rsp[8] : receiver
// -----------------------------------
......@@ -1286,7 +1289,11 @@ void Builtins::Generate_DatePrototype_GetField(MacroAssembler* masm,
__ bind(&receiver_not_date);
{
FrameScope scope(masm, StackFrame::MANUAL);
__ EnterFrame(StackFrame::INTERNAL);
__ Push(rbp);
__ Move(rbp, rsp);
__ Push(rsi);
__ Push(rdi);
__ Push(Immediate(0));
__ CallRuntime(Runtime::kThrowNotDateError);
}
}
......
......@@ -18,3 +18,21 @@ function testTraceNativeConversion(nativeFunc) {
testTraceNativeConversion(Math.max);
testTraceNativeConversion(Math.min);
function testBuiltinInStackTrace(script, nativeFuncName) {
try {
eval(script);
assertUnreachable(nativeFuncName);
} catch (e) {
assertTrue(e.stack.indexOf(nativeFuncName) >= 0, nativeFuncName);
}
}
// Use the full name ('String.getDate') in order to avoid false pass
// results when the method name is mentioned in the error message itself.
// This occurs, e.g., for Date.prototype.getYear, which uses a different code
// path and never hits the Generate_DatePrototype_GetField builtin.
testBuiltinInStackTrace("Date.prototype.getDate.call('')", "String.getDate");
testBuiltinInStackTrace("Date.prototype.getUTCDate.call('')",
"String.getUTCDate");
testBuiltinInStackTrace("Date.prototype.getTime.call('')", "String.getTime");
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment