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

Side by Side Diff: src/ast/variables.cc

Issue 2257493002: Better pack fields in Variable (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Merged master Created 4 years, 3 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
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 "src/ast/variables.h" 5 #include "src/ast/variables.h"
6 6
7 #include "src/ast/scopes.h" 7 #include "src/ast/scopes.h"
8 #include "src/globals.h" 8 #include "src/globals.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 15 matching lines...) Expand all
26 } 26 }
27 UNREACHABLE(); 27 UNREACHABLE();
28 return NULL; 28 return NULL;
29 } 29 }
30 30
31 Variable::Variable(Scope* scope, const AstRawString* name, VariableMode mode, 31 Variable::Variable(Scope* scope, const AstRawString* name, VariableMode mode,
32 Kind kind, InitializationFlag initialization_flag, 32 Kind kind, InitializationFlag initialization_flag,
33 MaybeAssignedFlag maybe_assigned_flag) 33 MaybeAssignedFlag maybe_assigned_flag)
34 : scope_(scope), 34 : scope_(scope),
35 name_(name), 35 name_(name),
36 mode_(mode), 36 local_if_not_shadowed_(nullptr),
37 kind_(kind),
38 location_(VariableLocation::UNALLOCATED),
39 index_(-1), 37 index_(-1),
40 initializer_position_(kNoSourcePosition), 38 initializer_position_(kNoSourcePosition),
41 local_if_not_shadowed_(NULL), 39 bit_field_(MaybeAssignedFlagField::encode(maybe_assigned_flag) |
42 force_context_allocation_(false), 40 InitializationFlagField::encode(initialization_flag) |
43 is_used_(false), 41 VariableModeField::encode(mode) | IsUsedField::encode(false) |
44 initialization_flag_(initialization_flag), 42 ForceContextAllocationField::encode(false) |
45 maybe_assigned_(maybe_assigned_flag) { 43 LocationField::encode(VariableLocation::UNALLOCATED) |
44 KindField::encode(kind)) {
46 // Var declared variables never need initialization. 45 // Var declared variables never need initialization.
47 DCHECK(!(mode == VAR && initialization_flag == kNeedsInitialization)); 46 DCHECK(!(mode == VAR && initialization_flag == kNeedsInitialization));
48 } 47 }
49 48
50 49
51 bool Variable::IsGlobalObjectProperty() const { 50 bool Variable::IsGlobalObjectProperty() const {
52 // Temporaries are never global, they must always be allocated in the 51 // Temporaries are never global, they must always be allocated in the
53 // activation frame. 52 // activation frame.
54 return (IsDynamicVariableMode(mode_) || 53 return (IsDynamicVariableMode(mode()) ||
55 (IsDeclaredVariableMode(mode_) && !IsLexicalVariableMode(mode_))) && 54 (IsDeclaredVariableMode(mode()) && !IsLexicalVariableMode(mode()))) &&
56 scope_ != NULL && scope_->is_script_scope(); 55 scope_ != NULL && scope_->is_script_scope();
57 } 56 }
58 57
59 58
60 bool Variable::IsStaticGlobalObjectProperty() const { 59 bool Variable::IsStaticGlobalObjectProperty() const {
61 // Temporaries are never global, they must always be allocated in the 60 // Temporaries are never global, they must always be allocated in the
62 // activation frame. 61 // activation frame.
63 return (IsDeclaredVariableMode(mode_) && !IsLexicalVariableMode(mode_)) && 62 return (IsDeclaredVariableMode(mode()) && !IsLexicalVariableMode(mode())) &&
64 scope_ != NULL && scope_->is_script_scope(); 63 scope_ != NULL && scope_->is_script_scope();
65 } 64 }
66 65
67 66
68 int Variable::CompareIndex(Variable* const* v, Variable* const* w) { 67 int Variable::CompareIndex(Variable* const* v, Variable* const* w) {
69 int x = (*v)->index(); 68 int x = (*v)->index();
70 int y = (*w)->index(); 69 int y = (*w)->index();
71 // Consider sorting them according to type as well? 70 // Consider sorting them according to type as well?
72 return x - y; 71 return x - y;
73 } 72 }
74 73
75 } // namespace internal 74 } // namespace internal
76 } // namespace v8 75 } // namespace v8
OLDNEW
« src/ast/variables.h ('K') | « src/ast/variables.h ('k') | src/globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698