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

Side by Side Diff: src/variables.cc

Issue 669270: Remove unneeded variable usage analysis. (Closed)
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
« no previous file with comments | « src/variables.h ('k') | tools/gyp/v8.gyp » ('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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 Mode mode, 90 Mode mode,
142 bool is_valid_LHS, 91 bool is_valid_LHS,
143 Kind kind) 92 Kind kind)
144 : scope_(scope), 93 : scope_(scope),
145 name_(name), 94 name_(name),
146 mode_(mode), 95 mode_(mode),
147 is_valid_LHS_(is_valid_LHS), 96 is_valid_LHS_(is_valid_LHS),
148 kind_(kind), 97 kind_(kind),
149 local_if_not_shadowed_(NULL), 98 local_if_not_shadowed_(NULL),
150 is_accessed_from_inner_scope_(false), 99 is_accessed_from_inner_scope_(false),
100 is_used_(false),
151 rewrite_(NULL) { 101 rewrite_(NULL) {
152 // names must be canonicalized for fast equality checks 102 // names must be canonicalized for fast equality checks
153 ASSERT(name->IsSymbol()); 103 ASSERT(name->IsSymbol());
154 } 104 }
155 105
156 106
157 bool Variable::is_global() const { 107 bool Variable::is_global() const {
158 // Temporaries are never global, they must always be allocated in the 108 // Temporaries are never global, they must always be allocated in the
159 // activation frame. 109 // activation frame.
160 return mode_ != TEMPORARY && scope_ != NULL && scope_->is_global_scope(); 110 return mode_ != TEMPORARY && scope_ != NULL && scope_->is_global_scope();
161 } 111 }
162 112
163 } } // namespace v8::internal 113 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/variables.h ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698