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

Side by Side Diff: vm/flow_graph_builder.cc

Issue 10409043: Make saving and restoring of the context around closure calls explicit. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 7 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
« no previous file with comments | « vm/flow_graph_builder.h ('k') | vm/flow_graph_compiler_x64.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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/flow_graph_builder.h" 5 #include "vm/flow_graph_builder.h"
6 6
7 #include "vm/ast_printer.h" 7 #include "vm/ast_printer.h"
8 #include "vm/bit_vector.h" 8 #include "vm/bit_vector.h"
9 #include "vm/code_descriptors.h" 9 #include "vm/code_descriptors.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 StaticCallComp* call = 1364 StaticCallComp* call =
1365 new StaticCallComp(node->token_index(), 1365 new StaticCallComp(node->token_index(),
1366 owner()->try_index(), 1366 owner()->try_index(),
1367 node->function(), 1367 node->function(),
1368 node->arguments()->names(), 1368 node->arguments()->names(),
1369 values); 1369 values);
1370 ReturnComputation(call); 1370 ReturnComputation(call);
1371 } 1371 }
1372 1372
1373 1373
1374 void EffectGraphVisitor::VisitClosureCallNode(ClosureCallNode* node) { 1374 ClosureCallComp* EffectGraphVisitor::BuildClosureCall(
1375 // Context is saved around the call, it's treated as an extra operand 1375 ClosureCallNode* node) {
1376 // consumed by the call (but not an argument).
1377 BindInstr* context = new BindInstr(new CurrentContextComp());
1378 AddInstruction(context);
1379
1380 ValueGraphVisitor for_closure(owner(), temp_index()); 1376 ValueGraphVisitor for_closure(owner(), temp_index());
1381 node->closure()->Visit(&for_closure); 1377 node->closure()->Visit(&for_closure);
1382 Append(for_closure); 1378 Append(for_closure);
1383 1379
1384 ZoneGrowableArray<Value*>* arguments = 1380 ZoneGrowableArray<Value*>* arguments =
1385 new ZoneGrowableArray<Value*>(node->arguments()->length()); 1381 new ZoneGrowableArray<Value*>(node->arguments()->length());
1386 arguments->Add(for_closure.value()); 1382 arguments->Add(for_closure.value());
1387 TranslateArgumentList(*node->arguments(), arguments); 1383 TranslateArgumentList(*node->arguments(), arguments);
1388 // First operand is the saved context, consumed by the call. 1384
1389 ClosureCallComp* call = new ClosureCallComp(node, 1385 // Save context around the call.
1390 owner()->try_index(), 1386 BuildStoreContext(*owner()->parsed_function().expression_temp_var());
1391 new UseVal(context), 1387 return new ClosureCallComp(node, owner()->try_index(), arguments);
1392 arguments); 1388 }
1393 ReturnComputation(call); 1389
1390
1391 void EffectGraphVisitor::VisitClosureCallNode(ClosureCallNode* node) {
1392 ClosureCallComp* call = BuildClosureCall(node);
1393 AddInstruction(new DoInstr(call));
1394
1395 // Restore context from saved location.
1396 BuildLoadContext(*owner()->parsed_function().expression_temp_var());
1397 }
1398
1399
1400 void ValueGraphVisitor::VisitClosureCallNode(ClosureCallNode* node) {
1401 ClosureCallComp* call = BuildClosureCall(node);
1402 BindInstr* result = new BindInstr(call);
1403 AddInstruction(result);
1404
1405 // Restore context from temp.
1406 BuildLoadContext(*owner()->parsed_function().expression_temp_var());
1407
1408 ReturnValue(new UseVal(result));
1394 } 1409 }
1395 1410
1396 1411
1397 void EffectGraphVisitor::VisitCloneContextNode(CloneContextNode* node) { 1412 void EffectGraphVisitor::VisitCloneContextNode(CloneContextNode* node) {
1398 BindInstr* context = new BindInstr(new CurrentContextComp()); 1413 BindInstr* context = new BindInstr(new CurrentContextComp());
1399 AddInstruction(context); 1414 AddInstruction(context);
1400 BindInstr* clone = 1415 BindInstr* clone =
1401 new BindInstr(new CloneContextComp(node->token_index(), 1416 new BindInstr(new CloneContextComp(node->token_index(),
1402 owner()->try_index(), 1417 owner()->try_index(),
1403 new UseVal(context))); 1418 new UseVal(context)));
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after
2379 char* chars = reinterpret_cast<char*>( 2394 char* chars = reinterpret_cast<char*>(
2380 Isolate::Current()->current_zone()->Allocate(len)); 2395 Isolate::Current()->current_zone()->Allocate(len));
2381 OS::SNPrint(chars, len, kFormat, function_name, reason); 2396 OS::SNPrint(chars, len, kFormat, function_name, reason);
2382 const Error& error = Error::Handle( 2397 const Error& error = Error::Handle(
2383 LanguageError::New(String::Handle(String::New(chars)))); 2398 LanguageError::New(String::Handle(String::New(chars))));
2384 Isolate::Current()->long_jump_base()->Jump(1, error); 2399 Isolate::Current()->long_jump_base()->Jump(1, error);
2385 } 2400 }
2386 2401
2387 2402
2388 } // namespace dart 2403 } // namespace dart
OLDNEW
« no previous file with comments | « vm/flow_graph_builder.h ('k') | vm/flow_graph_compiler_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698