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

Side by Side Diff: src/scopes.h

Issue 5753005: Make closures optimizable by Crankshaft compiler. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Next round Created 9 years, 11 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 | « src/runtime-profiler.cc ('k') | src/scopes.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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 void Print(int n = 0); // n = indentation; n < 0 => don't print recursively 295 void Print(int n = 0); // n = indentation; n < 0 => don't print recursively
296 #endif 296 #endif
297 297
298 // --------------------------------------------------------------------------- 298 // ---------------------------------------------------------------------------
299 // Implementation. 299 // Implementation.
300 protected: 300 protected:
301 friend class ParserFactory; 301 friend class ParserFactory;
302 302
303 explicit Scope(Type type); 303 explicit Scope(Type type);
304 304
305 void InsertAfterScope(Scope* scope) {
306 inner_scopes_.Add(scope);
307 outer_scope_ = scope->outer_scope_;
308 outer_scope_->inner_scopes_.RemoveElement(scope);
309 outer_scope_->inner_scopes_.Add(this);
310 scope->outer_scope_ = this;
311 }
312
305 // Scope tree. 313 // Scope tree.
306 Scope* outer_scope_; // the immediately enclosing outer scope, or NULL 314 Scope* outer_scope_; // the immediately enclosing outer scope, or NULL
307 ZoneList<Scope*> inner_scopes_; // the immediately enclosed inner scopes 315 ZoneList<Scope*> inner_scopes_; // the immediately enclosed inner scopes
308 316
309 // The scope type. 317 // The scope type.
310 Type type_; 318 Type type_;
311 319
312 // Debugging support. 320 // Debugging support.
313 Handle<String> scope_name_; 321 Handle<String> scope_name_;
314 322
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 // Computed via PropagateScopeInfo. 356 // Computed via PropagateScopeInfo.
349 bool outer_scope_calls_eval_; 357 bool outer_scope_calls_eval_;
350 bool inner_scope_calls_eval_; 358 bool inner_scope_calls_eval_;
351 bool outer_scope_is_eval_scope_; 359 bool outer_scope_is_eval_scope_;
352 bool force_eager_compilation_; 360 bool force_eager_compilation_;
353 361
354 // Computed via AllocateVariables; function scopes only. 362 // Computed via AllocateVariables; function scopes only.
355 int num_stack_slots_; 363 int num_stack_slots_;
356 int num_heap_slots_; 364 int num_heap_slots_;
357 365
366 // Serialized scopes support.
367 SerializedScopeInfo* scope_info_;
368 bool resolved() { return scope_info_ != NULL; }
369
358 // Create a non-local variable with a given name. 370 // Create a non-local variable with a given name.
359 // These variables are looked up dynamically at runtime. 371 // These variables are looked up dynamically at runtime.
360 Variable* NonLocal(Handle<String> name, Variable::Mode mode); 372 Variable* NonLocal(Handle<String> name, Variable::Mode mode);
361 373
362 // Variable resolution. 374 // Variable resolution.
363 Variable* LookupRecursive(Handle<String> name, 375 Variable* LookupRecursive(Handle<String> name,
364 bool inner_lookup, 376 bool inner_lookup,
365 Variable** invalidated_local); 377 Variable** invalidated_local);
366 void ResolveVariable(Scope* global_scope, 378 void ResolveVariable(Scope* global_scope,
367 Handle<Context> context, 379 Handle<Context> context,
(...skipping 11 matching lines...) Expand all
379 bool MustAllocateInContext(Variable* var); 391 bool MustAllocateInContext(Variable* var);
380 bool HasArgumentsParameter(); 392 bool HasArgumentsParameter();
381 393
382 // Variable allocation. 394 // Variable allocation.
383 void AllocateStackSlot(Variable* var); 395 void AllocateStackSlot(Variable* var);
384 void AllocateHeapSlot(Variable* var); 396 void AllocateHeapSlot(Variable* var);
385 void AllocateParameterLocals(); 397 void AllocateParameterLocals();
386 void AllocateNonParameterLocal(Variable* var); 398 void AllocateNonParameterLocal(Variable* var);
387 void AllocateNonParameterLocals(); 399 void AllocateNonParameterLocals();
388 void AllocateVariablesRecursively(); 400 void AllocateVariablesRecursively();
401
402 private:
403 Scope(Scope* inner_scope, SerializedScopeInfo* scope_info);
404
405 void SetDefaults(Type type,
406 Scope* outer_scope,
407 SerializedScopeInfo* scope_info) {
408 outer_scope_ = outer_scope;
409 type_ = type;
410 scope_name_ = Factory::empty_symbol();
411 dynamics_ = NULL;
412 receiver_ = NULL;
413 function_ = NULL;
414 arguments_ = NULL;
415 arguments_shadow_ = NULL;
416 illegal_redecl_ = NULL;
417 scope_inside_with_ = false;
418 scope_contains_with_ = false;
419 scope_calls_eval_ = false;
420 outer_scope_calls_eval_ = false;
421 inner_scope_calls_eval_ = false;
422 outer_scope_is_eval_scope_ = false;
423 force_eager_compilation_ = false;
424 num_stack_slots_ = 0;
425 num_heap_slots_ = 0;
426 scope_info_ = scope_info;
427 }
389 }; 428 };
390 429
391 430
392 // Scope used during pre-parsing. 431 // Scope used during pre-parsing.
393 class DummyScope : public Scope { 432 class DummyScope : public Scope {
394 public: 433 public:
395 DummyScope() 434 DummyScope()
396 : Scope(GLOBAL_SCOPE), 435 : Scope(GLOBAL_SCOPE),
397 nesting_level_(1), // Allows us to Leave the initial scope. 436 nesting_level_(1), // Allows us to Leave the initial scope.
398 inside_with_level_(kNotInsideWith) { 437 inside_with_level_(kNotInsideWith) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 int nesting_level_; 474 int nesting_level_;
436 // Nesting level of outermost scope that is contained in a with statement, 475 // Nesting level of outermost scope that is contained in a with statement,
437 // or kNotInsideWith if there are no with's around the current scope. 476 // or kNotInsideWith if there are no with's around the current scope.
438 int inside_with_level_; 477 int inside_with_level_;
439 }; 478 };
440 479
441 480
442 } } // namespace v8::internal 481 } } // namespace v8::internal
443 482
444 #endif // V8_SCOPES_H_ 483 #endif // V8_SCOPES_H_
OLDNEW
« no previous file with comments | « src/runtime-profiler.cc ('k') | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698