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

Unified Diff: runtime/vm/parser.cc

Issue 9664062: Support allocating and calling closures in the new non-optimizing compiler. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Incorporated review comments. Created 8 years, 9 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 | « runtime/vm/parser.h ('k') | runtime/vm/scopes.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index d768f81dc8ad484e283c33704e3211a1cdc49451..e39eed1445d8c331b99ef1bbaba8fa02b4c03280 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -112,6 +112,42 @@ static ThrowNode* CreateEvalConstConstructorThrow(intptr_t token_pos,
}
+void ParsedFunction::AllocateVariables() {
+ LocalScope* scope = node_sequence()->scope();
+ const int fixed_parameter_count = function().num_fixed_parameters();
+ const int optional_parameter_count = function().num_optional_parameters();
+ const int parameter_count = fixed_parameter_count + optional_parameter_count;
+ // Compute start indices to parameters and locals, and the number of
+ // parameters to copy.
+ if (optional_parameter_count == 0) {
+ // Parameter i will be at fp[1 + parameter_count - i] and local variable
+ // j will be at fp[-1 - j].
+ first_parameter_index_ = 1 + parameter_count;
+ first_stack_local_index_ = -1;
+ copied_parameter_count_ = 0;
+ } else {
+ // Parameter i will be at fp[-1 - i] and local variable j will be at
+ // fp[-1 - parameter_count - j].
+ first_parameter_index_ = -1;
+ first_stack_local_index_ = -1 - parameter_count;
+ copied_parameter_count_ = parameter_count;
+ }
+
+ // Allocate parameters and local variables, either in the local frame or
+ // in the context(s).
+ LocalScope* context_owner = NULL; // No context needed yet.
+ int next_free_frame_index =
+ scope->AllocateVariables(first_parameter_index_,
+ parameter_count,
+ first_stack_local_index_,
+ scope,
+ &context_owner);
+ // Frame indices are relative to the frame pointer and are decreasing.
+ ASSERT(next_free_frame_index <= first_stack_local_index_);
+ stack_local_count_ = first_stack_local_index_ - next_free_frame_index;
+}
+
+
struct Parser::Block : public ZoneAllocated {
Block(Block* outer_block, LocalScope* local_scope, SequenceNode* seq)
: parent(outer_block), scope(local_scope), statements(seq) {
« no previous file with comments | « runtime/vm/parser.h ('k') | runtime/vm/scopes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698