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

Side by Side Diff: src/variables.cc

Issue 844006: Merge changes up to V8 version 2.1.3 into the partial snapshots (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/partial_snapshots/
Patch Set: Created 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/variables.h ('k') | src/version.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 17 matching lines...) Expand all
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #include "ast.h" 30 #include "ast.h"
31 #include "scopes.h" 31 #include "scopes.h"
32 #include "variables.h" 32 #include "variables.h"
33 33
34 namespace v8 { 34 namespace v8 {
35 namespace internal { 35 namespace internal {
36 36
37 // ---------------------------------------------------------------------------- 37 // ----------------------------------------------------------------------------
38 // Implementation UseCount.
39
40 UseCount::UseCount()
41 : nreads_(0),
42 nwrites_(0) {
43 }
44
45
46 void UseCount::RecordRead(int weight) {
47 ASSERT(weight > 0);
48 nreads_ += weight;
49 // We must have a positive nreads_ here. Handle
50 // any kind of overflow by setting nreads_ to
51 // some large-ish value.
52 if (nreads_ <= 0) nreads_ = 1000000;
53 ASSERT(is_read() & is_used());
54 }
55
56
57 void UseCount::RecordWrite(int weight) {
58 ASSERT(weight > 0);
59 nwrites_ += weight;
60 // We must have a positive nwrites_ here. Handle
61 // any kind of overflow by setting nwrites_ to
62 // some large-ish value.
63 if (nwrites_ <= 0) nwrites_ = 1000000;
64 ASSERT(is_written() && is_used());
65 }
66
67
68 void UseCount::RecordAccess(int weight) {
69 RecordRead(weight);
70 RecordWrite(weight);
71 }
72
73
74 void UseCount::RecordUses(UseCount* uses) {
75 if (uses->nreads() > 0) RecordRead(uses->nreads());
76 if (uses->nwrites() > 0) RecordWrite(uses->nwrites());
77 }
78
79
80 #ifdef DEBUG
81 void UseCount::Print() {
82 // PrintF("r = %d, w = %d", nreads_, nwrites_);
83 PrintF("%du = %dr + %dw", nuses(), nreads(), nwrites());
84 }
85 #endif
86
87
88 // ----------------------------------------------------------------------------
89 // Implementation StaticType. 38 // Implementation StaticType.
90 39
91 40
92 const char* StaticType::Type2String(StaticType* type) { 41 const char* StaticType::Type2String(StaticType* type) {
93 switch (type->kind_) { 42 switch (type->kind_) {
94 case UNKNOWN: 43 case UNKNOWN:
95 return "UNKNOWN"; 44 return "UNKNOWN";
96 case LIKELY_SMI: 45 case LIKELY_SMI:
97 return "LIKELY_SMI"; 46 return "LIKELY_SMI";
98 default: 47 default:
(...skipping 30 matching lines...) Expand all
129 Variable* Variable::AsVariable() { 78 Variable* Variable::AsVariable() {
130 return rewrite_ == NULL || rewrite_->AsSlot() != NULL ? this : NULL; 79 return rewrite_ == NULL || rewrite_->AsSlot() != NULL ? this : NULL;
131 } 80 }
132 81
133 82
134 Slot* Variable::slot() const { 83 Slot* Variable::slot() const {
135 return rewrite_ != NULL ? rewrite_->AsSlot() : NULL; 84 return rewrite_ != NULL ? rewrite_->AsSlot() : NULL;
136 } 85 }
137 86
138 87
88 bool Variable::IsStackAllocated() const {
89 Slot* s = slot();
90 return s != NULL && s->IsStackAllocated();
91 }
92
93
139 Variable::Variable(Scope* scope, 94 Variable::Variable(Scope* scope,
140 Handle<String> name, 95 Handle<String> name,
141 Mode mode, 96 Mode mode,
142 bool is_valid_LHS, 97 bool is_valid_LHS,
143 Kind kind) 98 Kind kind)
144 : scope_(scope), 99 : scope_(scope),
145 name_(name), 100 name_(name),
146 mode_(mode), 101 mode_(mode),
147 is_valid_LHS_(is_valid_LHS), 102 is_valid_LHS_(is_valid_LHS),
148 kind_(kind), 103 kind_(kind),
149 local_if_not_shadowed_(NULL), 104 local_if_not_shadowed_(NULL),
150 is_accessed_from_inner_scope_(false), 105 is_accessed_from_inner_scope_(false),
106 is_used_(false),
151 rewrite_(NULL) { 107 rewrite_(NULL) {
152 // names must be canonicalized for fast equality checks 108 // names must be canonicalized for fast equality checks
153 ASSERT(name->IsSymbol()); 109 ASSERT(name->IsSymbol());
154 } 110 }
155 111
156 112
157 bool Variable::is_global() const { 113 bool Variable::is_global() const {
158 // Temporaries are never global, they must always be allocated in the 114 // Temporaries are never global, they must always be allocated in the
159 // activation frame. 115 // activation frame.
160 return mode_ != TEMPORARY && scope_ != NULL && scope_->is_global_scope(); 116 return mode_ != TEMPORARY && scope_ != NULL && scope_->is_global_scope();
161 } 117 }
162 118
163 } } // namespace v8::internal 119 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/variables.h ('k') | src/version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698