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

Side by Side Diff: src/variables.cc

Issue 231073002: WIP: Parser: delay string internalization. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: more cleanup Created 6 years, 6 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/variables.h ('k') | test/cctest/test-ast.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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "v8.h" 5 #include "v8.h"
6 6
7 #include "ast.h" 7 #include "ast.h"
8 #include "scopes.h" 8 #include "scopes.h"
9 #include "variables.h" 9 #include "variables.h"
10 10
(...skipping 15 matching lines...) Expand all
26 case DYNAMIC_LOCAL: return "DYNAMIC_LOCAL"; 26 case DYNAMIC_LOCAL: return "DYNAMIC_LOCAL";
27 case INTERNAL: return "INTERNAL"; 27 case INTERNAL: return "INTERNAL";
28 case TEMPORARY: return "TEMPORARY"; 28 case TEMPORARY: return "TEMPORARY";
29 } 29 }
30 UNREACHABLE(); 30 UNREACHABLE();
31 return NULL; 31 return NULL;
32 } 32 }
33 33
34 34
35 Variable::Variable(Scope* scope, 35 Variable::Variable(Scope* scope,
36 Handle<String> name, 36 const AstString* name,
37 VariableMode mode, 37 VariableMode mode,
38 bool is_valid_ref, 38 bool is_valid_ref,
39 Kind kind, 39 Kind kind,
40 InitializationFlag initialization_flag, 40 InitializationFlag initialization_flag,
41 Interface* interface) 41 Interface* interface)
42 : scope_(scope), 42 : scope_(scope),
43 name_(name), 43 name_(name),
44 mode_(mode), 44 mode_(mode),
45 kind_(kind), 45 kind_(kind),
46 location_(UNALLOCATED), 46 location_(UNALLOCATED),
47 index_(-1), 47 index_(-1),
48 initializer_position_(RelocInfo::kNoPosition), 48 initializer_position_(RelocInfo::kNoPosition),
49 local_if_not_shadowed_(NULL), 49 local_if_not_shadowed_(NULL),
50 is_valid_ref_(is_valid_ref), 50 is_valid_ref_(is_valid_ref),
51 force_context_allocation_(false), 51 force_context_allocation_(false),
52 is_used_(false), 52 is_used_(false),
53 initialization_flag_(initialization_flag), 53 initialization_flag_(initialization_flag),
54 interface_(interface) { 54 interface_(interface) {
55 // Names must be canonicalized for fast equality checks.
56 ASSERT(name->IsInternalizedString());
57 // Var declared variables never need initialization. 55 // Var declared variables never need initialization.
58 ASSERT(!(mode == VAR && initialization_flag == kNeedsInitialization)); 56 ASSERT(!(mode == VAR && initialization_flag == kNeedsInitialization));
59 } 57 }
60 58
61 59
62 bool Variable::IsGlobalObjectProperty() const { 60 bool Variable::IsGlobalObjectProperty() const {
63 // Temporaries are never global, they must always be allocated in the 61 // Temporaries are never global, they must always be allocated in the
64 // activation frame. 62 // activation frame.
65 return (IsDynamicVariableMode(mode_) || 63 return (IsDynamicVariableMode(mode_) ||
66 (IsDeclaredVariableMode(mode_) && !IsLexicalVariableMode(mode_))) 64 (IsDeclaredVariableMode(mode_) && !IsLexicalVariableMode(mode_)))
67 && scope_ != NULL && scope_->is_global_scope(); 65 && scope_ != NULL && scope_->is_global_scope();
68 } 66 }
69 67
70 68
71 int Variable::CompareIndex(Variable* const* v, Variable* const* w) { 69 int Variable::CompareIndex(Variable* const* v, Variable* const* w) {
72 int x = (*v)->index(); 70 int x = (*v)->index();
73 int y = (*w)->index(); 71 int y = (*w)->index();
74 // Consider sorting them according to type as well? 72 // Consider sorting them according to type as well?
75 return x - y; 73 return x - y;
76 } 74 }
77 75
78 } } // namespace v8::internal 76 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/variables.h ('k') | test/cctest/test-ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698