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

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

Issue 7280012: Introduce scopes to keep track of catch blocks at compile time. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Update to HEAD. Created 9 years, 5 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 unified diff | Download patch | Annotate | Revision Log
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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 } 394 }
395 395
396 396
397 int FullCodeGenerator::SlotOffset(Slot* slot) { 397 int FullCodeGenerator::SlotOffset(Slot* slot) {
398 ASSERT(slot != NULL); 398 ASSERT(slot != NULL);
399 // Offset is negative because higher indexes are at lower addresses. 399 // Offset is negative because higher indexes are at lower addresses.
400 int offset = -slot->index() * kPointerSize; 400 int offset = -slot->index() * kPointerSize;
401 // Adjust by a (parameter or local) base offset. 401 // Adjust by a (parameter or local) base offset.
402 switch (slot->type()) { 402 switch (slot->type()) {
403 case Slot::PARAMETER: 403 case Slot::PARAMETER:
404 offset += (scope()->num_parameters() + 1) * kPointerSize; 404 offset += (info_->scope()->num_parameters() + 1) * kPointerSize;
Mads Ager (chromium) 2011/06/30 12:08:32 Do you need this change? Don't you have a scope he
Kevin Millikin (Chromium) 2011/06/30 12:30:06 This definitely needs to be the function's scope (
Mads Ager (chromium) 2011/06/30 12:47:44 Should we create an accessor for that then: functi
405 break; 405 break;
406 case Slot::LOCAL: 406 case Slot::LOCAL:
407 offset += JavaScriptFrameConstants::kLocal0Offset; 407 offset += JavaScriptFrameConstants::kLocal0Offset;
408 break; 408 break;
409 case Slot::CONTEXT: 409 case Slot::CONTEXT:
410 case Slot::LOOKUP: 410 case Slot::LOOKUP:
411 UNREACHABLE(); 411 UNREACHABLE();
412 } 412 }
413 return offset; 413 return offset;
414 } 414 }
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 // executing the catch block. The catch block has been rewritten 1099 // executing the catch block. The catch block has been rewritten
1100 // to introduce a new scope to bind the catch variable and to remove 1100 // to introduce a new scope to bind the catch variable and to remove
1101 // that scope again afterwards. 1101 // that scope again afterwards.
1102 1102
1103 Label try_handler_setup, catch_entry, done; 1103 Label try_handler_setup, catch_entry, done;
1104 __ Call(&try_handler_setup); 1104 __ Call(&try_handler_setup);
1105 // Try handler code, exception in result register. 1105 // Try handler code, exception in result register.
1106 1106
1107 // Extend the context before executing the catch block. 1107 // Extend the context before executing the catch block.
1108 { Comment cmnt(masm_, "[ Extend catch context"); 1108 { Comment cmnt(masm_, "[ Extend catch context");
1109 __ Push(stmt->name()); 1109 __ Push(stmt->variable()->name());
1110 __ push(result_register()); 1110 __ push(result_register());
1111 PushFunctionArgumentForContextAllocation(); 1111 PushFunctionArgumentForContextAllocation();
1112 __ CallRuntime(Runtime::kPushCatchContext, 3); 1112 __ CallRuntime(Runtime::kPushCatchContext, 3);
1113 StoreToFrameField(StandardFrameConstants::kContextOffset, 1113 StoreToFrameField(StandardFrameConstants::kContextOffset,
1114 context_register()); 1114 context_register());
1115 } 1115 }
1116 1116
1117 Scope* saved_scope = scope();
Mads Ager (chromium) 2011/06/30 12:08:32 Could use a comment? We could create a scope objec
Kevin Millikin (Chromium) 2011/06/30 12:30:06 It's only used here and I couldn't think of a comm
Mads Ager (chromium) 2011/06/30 12:47:44 Not sure anything is really needed. You are right
1118 scope_ = stmt->scope();
1119 ASSERT(scope_->declarations()->is_empty());
1117 Visit(stmt->catch_block()); 1120 Visit(stmt->catch_block());
1121 scope_ = saved_scope;
1118 __ jmp(&done); 1122 __ jmp(&done);
1119 1123
1120 // Try block code. Sets up the exception handler chain. 1124 // Try block code. Sets up the exception handler chain.
1121 __ bind(&try_handler_setup); 1125 __ bind(&try_handler_setup);
1122 { 1126 {
1123 TryCatch try_block(this, &catch_entry); 1127 TryCatch try_block(this, &catch_entry);
1124 __ PushTryHandler(IN_JAVASCRIPT, TRY_CATCH_HANDLER); 1128 __ PushTryHandler(IN_JAVASCRIPT, TRY_CATCH_HANDLER);
1125 Visit(stmt->try_block()); 1129 Visit(stmt->try_block());
1126 __ PopTryHandler(); 1130 __ PopTryHandler();
1127 } 1131 }
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 } 1313 }
1310 1314
1311 return false; 1315 return false;
1312 } 1316 }
1313 1317
1314 1318
1315 #undef __ 1319 #undef __
1316 1320
1317 1321
1318 } } // namespace v8::internal 1322 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698