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

Side by Side Diff: src/full-codegen.cc

Issue 8340023: Remove stack height tracking from ia32 non-optimizing code generator. Reverts change 8755. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/full-codegen.h ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 } 403 }
404 404
405 405
406 void FullCodeGenerator::AccumulatorValueContext::Plug(Register reg) const { 406 void FullCodeGenerator::AccumulatorValueContext::Plug(Register reg) const {
407 __ Move(result_register(), reg); 407 __ Move(result_register(), reg);
408 } 408 }
409 409
410 410
411 void FullCodeGenerator::StackValueContext::Plug(Register reg) const { 411 void FullCodeGenerator::StackValueContext::Plug(Register reg) const {
412 __ push(reg); 412 __ push(reg);
413 codegen()->increment_stack_height();
414 } 413 }
415 414
416 415
417 void FullCodeGenerator::TestContext::Plug(Register reg) const { 416 void FullCodeGenerator::TestContext::Plug(Register reg) const {
418 // For simplicity we always test the accumulator register. 417 // For simplicity we always test the accumulator register.
419 __ Move(result_register(), reg); 418 __ Move(result_register(), reg);
420 codegen()->PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL); 419 codegen()->PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL);
421 codegen()->DoTest(this); 420 codegen()->DoTest(this);
422 } 421 }
423 422
424 423
425 void FullCodeGenerator::EffectContext::PlugTOS() const { 424 void FullCodeGenerator::EffectContext::PlugTOS() const {
426 __ Drop(1); 425 __ Drop(1);
427 codegen()->decrement_stack_height();
428 } 426 }
429 427
430 428
431 void FullCodeGenerator::AccumulatorValueContext::PlugTOS() const { 429 void FullCodeGenerator::AccumulatorValueContext::PlugTOS() const {
432 __ pop(result_register()); 430 __ pop(result_register());
433 codegen()->decrement_stack_height();
434 } 431 }
435 432
436 433
437 void FullCodeGenerator::StackValueContext::PlugTOS() const { 434 void FullCodeGenerator::StackValueContext::PlugTOS() const {
438 } 435 }
439 436
440 437
441 void FullCodeGenerator::TestContext::PlugTOS() const { 438 void FullCodeGenerator::TestContext::PlugTOS() const {
442 // For simplicity we always test the accumulator register. 439 // For simplicity we always test the accumulator register.
443 __ pop(result_register()); 440 __ pop(result_register());
444 codegen()->decrement_stack_height();
445 codegen()->PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL); 441 codegen()->PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL);
446 codegen()->DoTest(this); 442 codegen()->DoTest(this);
447 } 443 }
448 444
449 445
450 void FullCodeGenerator::EffectContext::PrepareTest( 446 void FullCodeGenerator::EffectContext::PrepareTest(
451 Label* materialize_true, 447 Label* materialize_true,
452 Label* materialize_false, 448 Label* materialize_false,
453 Label** if_true, 449 Label** if_true,
454 Label** if_false, 450 Label** if_false,
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 } 968 }
973 969
974 970
975 void FullCodeGenerator::VisitWithStatement(WithStatement* stmt) { 971 void FullCodeGenerator::VisitWithStatement(WithStatement* stmt) {
976 Comment cmnt(masm_, "[ WithStatement"); 972 Comment cmnt(masm_, "[ WithStatement");
977 SetStatementPosition(stmt); 973 SetStatementPosition(stmt);
978 974
979 VisitForStackValue(stmt->expression()); 975 VisitForStackValue(stmt->expression());
980 PushFunctionArgumentForContextAllocation(); 976 PushFunctionArgumentForContextAllocation();
981 __ CallRuntime(Runtime::kPushWithContext, 2); 977 __ CallRuntime(Runtime::kPushWithContext, 2);
982 decrement_stack_height();
983 StoreToFrameField(StandardFrameConstants::kContextOffset, context_register()); 978 StoreToFrameField(StandardFrameConstants::kContextOffset, context_register());
984 979
985 { WithOrCatch body(this); 980 { WithOrCatch body(this);
986 Visit(stmt->statement()); 981 Visit(stmt->statement());
987 } 982 }
988 983
989 // Pop context. 984 // Pop context.
990 LoadContextField(context_register(), Context::PREVIOUS_INDEX); 985 LoadContextField(context_register(), Context::PREVIOUS_INDEX);
991 // Update local stack frame context field. 986 // Update local stack frame context field.
992 StoreToFrameField(StandardFrameConstants::kContextOffset, context_register()); 987 StoreToFrameField(StandardFrameConstants::kContextOffset, context_register());
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 } 1137 }
1143 // Restore the context. 1138 // Restore the context.
1144 LoadContextField(context_register(), Context::PREVIOUS_INDEX); 1139 LoadContextField(context_register(), Context::PREVIOUS_INDEX);
1145 StoreToFrameField(StandardFrameConstants::kContextOffset, context_register()); 1140 StoreToFrameField(StandardFrameConstants::kContextOffset, context_register());
1146 scope_ = saved_scope; 1141 scope_ = saved_scope;
1147 __ jmp(&done); 1142 __ jmp(&done);
1148 1143
1149 // Try block code. Sets up the exception handler chain. 1144 // Try block code. Sets up the exception handler chain.
1150 __ bind(&try_handler_setup); 1145 __ bind(&try_handler_setup);
1151 { 1146 {
1152 const int delta = StackHandlerConstants::kSize / kPointerSize;
1153 TryCatch try_block(this); 1147 TryCatch try_block(this);
1154 __ PushTryHandler(IN_JAVASCRIPT, TRY_CATCH_HANDLER); 1148 __ PushTryHandler(IN_JAVASCRIPT, TRY_CATCH_HANDLER);
1155 increment_stack_height(delta);
1156 Visit(stmt->try_block()); 1149 Visit(stmt->try_block());
1157 __ PopTryHandler(); 1150 __ PopTryHandler();
1158 decrement_stack_height(delta);
1159 } 1151 }
1160 __ bind(&done); 1152 __ bind(&done);
1161 } 1153 }
1162 1154
1163 1155
1164 void FullCodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* stmt) { 1156 void FullCodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* stmt) {
1165 Comment cmnt(masm_, "[ TryFinallyStatement"); 1157 Comment cmnt(masm_, "[ TryFinallyStatement");
1166 SetStatementPosition(stmt); 1158 SetStatementPosition(stmt);
1167 // Try finally is compiled by setting up a try-handler on the stack while 1159 // Try finally is compiled by setting up a try-handler on the stack while
1168 // executing the try body, and removing it again afterwards. 1160 // executing the try body, and removing it again afterwards.
(...skipping 11 matching lines...) Expand all
1180 // handler code. The handler code then calls the finally-block before 1172 // handler code. The handler code then calls the finally-block before
1181 // rethrowing the exception. 1173 // rethrowing the exception.
1182 // 1174 //
1183 // The finally block must assume a return address on top of the stack 1175 // The finally block must assume a return address on top of the stack
1184 // (or in the link register on ARM chips) and a value (return value or 1176 // (or in the link register on ARM chips) and a value (return value or
1185 // exception) in the result register (rax/eax/r0), both of which must 1177 // exception) in the result register (rax/eax/r0), both of which must
1186 // be preserved. The return address isn't GC-safe, so it should be 1178 // be preserved. The return address isn't GC-safe, so it should be
1187 // cooked before GC. 1179 // cooked before GC.
1188 Label finally_entry; 1180 Label finally_entry;
1189 Label try_handler_setup; 1181 Label try_handler_setup;
1190 const int original_stack_height = stack_height();
1191 1182
1192 // Setup the try-handler chain. Use a call to 1183 // Setup the try-handler chain. Use a call to
1193 // Jump to try-handler setup and try-block code. Use call to put try-handler 1184 // Jump to try-handler setup and try-block code. Use call to put try-handler
1194 // address on stack. 1185 // address on stack.
1195 __ Call(&try_handler_setup); 1186 __ Call(&try_handler_setup);
1196 // Try handler code. Return address of call is pushed on handler stack. 1187 // Try handler code. Return address of call is pushed on handler stack.
1197 { 1188 {
1198 // This code is only executed during stack-handler traversal when an 1189 // This code is only executed during stack-handler traversal when an
1199 // exception is thrown. The exception is in the result register, which 1190 // exception is thrown. The exception is in the result register, which
1200 // is retained by the finally block. 1191 // is retained by the finally block.
1201 // Call the finally block and then rethrow the exception if it returns. 1192 // Call the finally block and then rethrow the exception if it returns.
1202 __ Call(&finally_entry); 1193 __ Call(&finally_entry);
1203 __ push(result_register()); 1194 __ push(result_register());
1204 __ CallRuntime(Runtime::kReThrow, 1); 1195 __ CallRuntime(Runtime::kReThrow, 1);
1205 } 1196 }
1206 1197
1207 __ bind(&finally_entry); 1198 __ bind(&finally_entry);
1208 { 1199 {
1209 // Finally block implementation. 1200 // Finally block implementation.
1210 Finally finally_block(this); 1201 Finally finally_block(this);
1211 EnterFinallyBlock(); 1202 EnterFinallyBlock();
1212 set_stack_height(original_stack_height + Finally::kElementCount);
1213 Visit(stmt->finally_block()); 1203 Visit(stmt->finally_block());
1214 ExitFinallyBlock(); // Return to the calling code. 1204 ExitFinallyBlock(); // Return to the calling code.
1215 } 1205 }
1216 1206
1217 __ bind(&try_handler_setup); 1207 __ bind(&try_handler_setup);
1218 { 1208 {
1219 // Setup try handler (stack pointer registers). 1209 // Setup try handler (stack pointer registers).
1220 const int delta = StackHandlerConstants::kSize / kPointerSize;
1221 TryFinally try_block(this, &finally_entry); 1210 TryFinally try_block(this, &finally_entry);
1222 __ PushTryHandler(IN_JAVASCRIPT, TRY_FINALLY_HANDLER); 1211 __ PushTryHandler(IN_JAVASCRIPT, TRY_FINALLY_HANDLER);
1223 set_stack_height(original_stack_height + delta);
1224 Visit(stmt->try_block()); 1212 Visit(stmt->try_block());
1225 __ PopTryHandler(); 1213 __ PopTryHandler();
1226 set_stack_height(original_stack_height);
1227 } 1214 }
1228 // Execute the finally block on the way out. Clobber the unpredictable 1215 // Execute the finally block on the way out. Clobber the unpredictable
1229 // value in the accumulator with one that's safe for GC. The finally 1216 // value in the accumulator with one that's safe for GC. The finally
1230 // block will unconditionally preserve the accumulator on the stack. 1217 // block will unconditionally preserve the accumulator on the stack.
1231 ClearAccumulator(); 1218 ClearAccumulator();
1232 __ Call(&finally_entry); 1219 __ Call(&finally_entry);
1233 } 1220 }
1234 1221
1235 1222
1236 void FullCodeGenerator::VisitDebuggerStatement(DebuggerStatement* stmt) { 1223 void FullCodeGenerator::VisitDebuggerStatement(DebuggerStatement* stmt) {
1237 #ifdef ENABLE_DEBUGGER_SUPPORT 1224 #ifdef ENABLE_DEBUGGER_SUPPORT
1238 Comment cmnt(masm_, "[ DebuggerStatement"); 1225 Comment cmnt(masm_, "[ DebuggerStatement");
1239 SetStatementPosition(stmt); 1226 SetStatementPosition(stmt);
1240 1227
1241 __ DebugBreak(); 1228 __ DebugBreak();
1242 // Ignore the return value. 1229 // Ignore the return value.
1243 #endif 1230 #endif
1244 } 1231 }
1245 1232
1246 1233
1247 void FullCodeGenerator::VisitConditional(Conditional* expr) { 1234 void FullCodeGenerator::VisitConditional(Conditional* expr) {
1248 Comment cmnt(masm_, "[ Conditional"); 1235 Comment cmnt(masm_, "[ Conditional");
1249 Label true_case, false_case, done; 1236 Label true_case, false_case, done;
1250 VisitForControl(expr->condition(), &true_case, &false_case, &true_case); 1237 VisitForControl(expr->condition(), &true_case, &false_case, &true_case);
1251 1238
1252 PrepareForBailoutForId(expr->ThenId(), NO_REGISTERS); 1239 PrepareForBailoutForId(expr->ThenId(), NO_REGISTERS);
1253 __ bind(&true_case); 1240 __ bind(&true_case);
1254 SetExpressionPosition(expr->then_expression(), 1241 SetExpressionPosition(expr->then_expression(),
1255 expr->then_expression_position()); 1242 expr->then_expression_position());
1256 int start_stack_height = stack_height();
1257 if (context()->IsTest()) { 1243 if (context()->IsTest()) {
1258 const TestContext* for_test = TestContext::cast(context()); 1244 const TestContext* for_test = TestContext::cast(context());
1259 VisitForControl(expr->then_expression(), 1245 VisitForControl(expr->then_expression(),
1260 for_test->true_label(), 1246 for_test->true_label(),
1261 for_test->false_label(), 1247 for_test->false_label(),
1262 NULL); 1248 NULL);
1263 } else { 1249 } else {
1264 VisitInCurrentContext(expr->then_expression()); 1250 VisitInCurrentContext(expr->then_expression());
1265 __ jmp(&done); 1251 __ jmp(&done);
1266 } 1252 }
1267 1253
1268 PrepareForBailoutForId(expr->ElseId(), NO_REGISTERS); 1254 PrepareForBailoutForId(expr->ElseId(), NO_REGISTERS);
1269 __ bind(&false_case); 1255 __ bind(&false_case);
1270 set_stack_height(start_stack_height);
1271 if (context()->IsTest()) ForwardBailoutToChild(expr); 1256 if (context()->IsTest()) ForwardBailoutToChild(expr);
1272 SetExpressionPosition(expr->else_expression(), 1257 SetExpressionPosition(expr->else_expression(),
1273 expr->else_expression_position()); 1258 expr->else_expression_position());
1274 VisitInCurrentContext(expr->else_expression()); 1259 VisitInCurrentContext(expr->else_expression());
1275 // If control flow falls through Visit, merge it with true case here. 1260 // If control flow falls through Visit, merge it with true case here.
1276 if (!context()->IsTest()) { 1261 if (!context()->IsTest()) {
1277 __ bind(&done); 1262 __ bind(&done);
1278 } 1263 }
1279 } 1264 }
1280 1265
(...skipping 20 matching lines...) Expand all
1301 1286
1302 void FullCodeGenerator::VisitSharedFunctionInfoLiteral( 1287 void FullCodeGenerator::VisitSharedFunctionInfoLiteral(
1303 SharedFunctionInfoLiteral* expr) { 1288 SharedFunctionInfoLiteral* expr) {
1304 Comment cmnt(masm_, "[ SharedFunctionInfoLiteral"); 1289 Comment cmnt(masm_, "[ SharedFunctionInfoLiteral");
1305 EmitNewClosure(expr->shared_function_info(), false); 1290 EmitNewClosure(expr->shared_function_info(), false);
1306 } 1291 }
1307 1292
1308 1293
1309 void FullCodeGenerator::VisitThrow(Throw* expr) { 1294 void FullCodeGenerator::VisitThrow(Throw* expr) {
1310 Comment cmnt(masm_, "[ Throw"); 1295 Comment cmnt(masm_, "[ Throw");
1311 // Throw has no effect on the stack height or the current expression context.
1312 // Usually the expression context is null, because throw is a statement.
1313 VisitForStackValue(expr->exception()); 1296 VisitForStackValue(expr->exception());
1314 __ CallRuntime(Runtime::kThrow, 1); 1297 __ CallRuntime(Runtime::kThrow, 1);
1315 decrement_stack_height();
1316 // Never returns here. 1298 // Never returns here.
1317 } 1299 }
1318 1300
1319 1301
1320 FullCodeGenerator::NestedStatement* FullCodeGenerator::TryCatch::Exit( 1302 FullCodeGenerator::NestedStatement* FullCodeGenerator::TryCatch::Exit(
1321 int* stack_depth, 1303 int* stack_depth,
1322 int* context_length) { 1304 int* context_length) {
1323 // The macros used here must preserve the result register. 1305 // The macros used here must preserve the result register.
1324 __ Drop(*stack_depth); 1306 __ Drop(*stack_depth);
1325 __ PopTryHandler(); 1307 __ PopTryHandler();
(...skipping 21 matching lines...) Expand all
1347 } 1329 }
1348 1330
1349 return false; 1331 return false;
1350 } 1332 }
1351 1333
1352 1334
1353 #undef __ 1335 #undef __
1354 1336
1355 1337
1356 } } // namespace v8::internal 1338 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/full-codegen.h ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698