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

Unified Diff: src/arm/full-codegen-arm.cc

Issue 939633002: Check stack size before pushing many arguments. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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 | « no previous file | src/full-codegen.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/arm/full-codegen-arm.cc
diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc
index 885f3ba2759493b761341418ca03e3b12a5f3023..b5d160b8ea173b2675fd22eb0c320cdc260c6d6c 100644
--- a/src/arm/full-codegen-arm.cc
+++ b/src/arm/full-codegen-arm.cc
@@ -155,15 +155,7 @@ void FullCodeGenerator::Generate() {
// Generators allocate locals, if any, in context slots.
DCHECK(!IsGeneratorFunction(info->function()->kind()) || locals_count == 0);
if (locals_count > 0) {
- if (locals_count >= 128) {
- Label ok;
- __ sub(r9, sp, Operand(locals_count * kPointerSize));
- __ LoadRoot(r2, Heap::kRealStackLimitRootIndex);
- __ cmp(r9, Operand(r2));
- __ b(hs, &ok);
- __ InvokeBuiltin(Builtins::STACK_OVERFLOW, CALL_FUNCTION);
- __ bind(&ok);
- }
+ EmitPreemptiveStackCheck(locals_count);
__ LoadRoot(r9, Heap::kUndefinedValueRootIndex);
int kMaxPushes = FLAG_optimize_for_size ? 4 : 32;
if (locals_count >= kMaxPushes) {
@@ -3035,6 +3027,9 @@ void FullCodeGenerator::EmitCall(Call* expr, CallICState::CallType call_type) {
// Load the arguments.
ZoneList<Expression*>* args = expr->arguments();
int arg_count = args->length();
+
+ EmitPreemptiveStackCheck(arg_count);
+
{ PreservePositionScope scope(masm()->positions_recorder());
for (int i = 0; i < arg_count; i++) {
VisitForStackValue(args->at(i));
@@ -5216,6 +5211,19 @@ void FullCodeGenerator::EmitLiteralCompareNil(CompareOperation* expr,
}
+void FullCodeGenerator::EmitPreemptiveStackCheck(int required_stack_size) {
+ if (required_stack_size >= 128) {
+ Label ok;
+ __ sub(r9, sp, Operand(required_stack_size * kPointerSize));
+ __ LoadRoot(r2, Heap::kRealStackLimitRootIndex);
+ __ cmp(r9, Operand(r2));
+ __ b(hs, &ok);
+ __ InvokeBuiltin(Builtins::STACK_OVERFLOW, CALL_FUNCTION);
+ __ bind(&ok);
+ }
+}
+
+
void FullCodeGenerator::VisitThisFunction(ThisFunction* expr) {
__ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
context()->Plug(r0);
« no previous file with comments | « no previous file | src/full-codegen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698