Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(475)

Unified Diff: src/mips64/builtins-mips64.cc

Issue 1391543002: [builtins] Make sure argument count is always valid for C++ builtins. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove extra newline. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/mips/builtins-mips.cc ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/mips64/builtins-mips64.cc
diff --git a/src/mips64/builtins-mips64.cc b/src/mips64/builtins-mips64.cc
index 5e62904b4434f9409c40c7126dd6d1f3239ccfaf..aaae528008c8272601a8ee14dbefe49a67e4929c 100644
--- a/src/mips64/builtins-mips64.cc
+++ b/src/mips64/builtins-mips64.cc
@@ -22,8 +22,9 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm,
BuiltinExtraArguments extra_args) {
// ----------- S t a t e -------------
// -- a0 : number of arguments excluding receiver
- // -- a1 : called function (only guaranteed when
- // -- extra_args requires it)
+ // (only guaranteed when the called function
+ // is not marked as DontAdaptArguments)
+ // -- a1 : called function
// -- sp[0] : last argument
// -- ...
// -- sp[8 * (argc - 1)] : first argument
@@ -48,8 +49,21 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm,
}
// JumpToExternalReference expects a0 to contain the number of arguments
- // including the receiver and the extra arguments.
+ // including the receiver and the extra arguments. But a0 is only valid
+ // if the called function is marked as DontAdaptArguments, otherwise we
+ // need to load the argument count from the SharedFunctionInfo.
+ Label argc, done_argc;
+ __ ld(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset));
+ __ lw(a2,
+ FieldMemOperand(a2, SharedFunctionInfo::kFormalParameterCountOffset));
+ __ Branch(&argc, ne, a2,
+ Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel));
+ __ Daddu(a0, a2, num_extra_args + 1);
+ __ jmp(&done_argc);
+ __ bind(&argc);
__ Daddu(a0, a0, num_extra_args + 1);
+ __ bind(&done_argc);
+
__ JumpToExternalReference(ExternalReference(id, masm->isolate()));
}
« no previous file with comments | « src/mips/builtins-mips.cc ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698