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

Side by Side Diff: src/compiler.h

Issue 8355038: Port r9643 to 3.2 branch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.2
Patch Set: Created 9 years, 2 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 | « no previous file | src/compiler.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 // 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 void MarkAsStrictMode() { 76 void MarkAsStrictMode() {
77 flags_ |= IsStrictMode::encode(true); 77 flags_ |= IsStrictMode::encode(true);
78 } 78 }
79 StrictModeFlag StrictMode() { 79 StrictModeFlag StrictMode() {
80 return is_strict_mode() ? kStrictMode : kNonStrictMode; 80 return is_strict_mode() ? kStrictMode : kNonStrictMode;
81 } 81 }
82 void MarkAsInLoop() { 82 void MarkAsInLoop() {
83 ASSERT(is_lazy()); 83 ASSERT(is_lazy());
84 flags_ |= IsInLoop::encode(true); 84 flags_ |= IsInLoop::encode(true);
85 } 85 }
86 void MarkAsAllowingNativesSyntax() { 86 void MarkAsNative() {
87 flags_ |= IsNativesSyntaxAllowed::encode(true); 87 flags_ |= IsNative::encode(true);
88 } 88 }
89 bool allows_natives_syntax() const { 89 bool is_native() const {
90 return IsNativesSyntaxAllowed::decode(flags_); 90 return IsNative::decode(flags_);
91 } 91 }
92 void SetFunction(FunctionLiteral* literal) { 92 void SetFunction(FunctionLiteral* literal) {
93 ASSERT(function_ == NULL); 93 ASSERT(function_ == NULL);
94 function_ = literal; 94 function_ = literal;
95 } 95 }
96 void SetScope(Scope* scope) { 96 void SetScope(Scope* scope) {
97 ASSERT(scope_ == NULL); 97 ASSERT(scope_ == NULL);
98 scope_ = scope; 98 scope_ = scope;
99 } 99 }
100 void SetCode(Handle<Code> code) { code_ = code; } 100 void SetCode(Handle<Code> code) { code_ = code; }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 enum Mode { 156 enum Mode {
157 BASE, 157 BASE,
158 OPTIMIZE, 158 OPTIMIZE,
159 NONOPT 159 NONOPT
160 }; 160 };
161 161
162 CompilationInfo() : function_(NULL) {} 162 CompilationInfo() : function_(NULL) {}
163 163
164 void Initialize(Mode mode) { 164 void Initialize(Mode mode) {
165 mode_ = V8::UseCrankshaft() ? mode : NONOPT; 165 mode_ = V8::UseCrankshaft() ? mode : NONOPT;
166 if (script_->type()->value() == Script::TYPE_NATIVE) {
167 MarkAsNative();
168 }
166 if (!shared_info_.is_null() && shared_info_->strict_mode()) { 169 if (!shared_info_.is_null() && shared_info_->strict_mode()) {
167 MarkAsStrictMode(); 170 MarkAsStrictMode();
168 } 171 }
169 } 172 }
170 173
171 void SetMode(Mode mode) { 174 void SetMode(Mode mode) {
172 ASSERT(V8::UseCrankshaft()); 175 ASSERT(V8::UseCrankshaft());
173 mode_ = mode; 176 mode_ = mode;
174 } 177 }
175 178
176 // Flags using template class BitField<type, start, length>. All are 179 // Flags using template class BitField<type, start, length>. All are
177 // false by default. 180 // false by default.
178 // 181 //
179 // Compilation is either eager or lazy. 182 // Compilation is either eager or lazy.
180 class IsLazy: public BitField<bool, 0, 1> {}; 183 class IsLazy: public BitField<bool, 0, 1> {};
181 // Flags that can be set for eager compilation. 184 // Flags that can be set for eager compilation.
182 class IsEval: public BitField<bool, 1, 1> {}; 185 class IsEval: public BitField<bool, 1, 1> {};
183 class IsGlobal: public BitField<bool, 2, 1> {}; 186 class IsGlobal: public BitField<bool, 2, 1> {};
184 // Flags that can be set for lazy compilation. 187 // Flags that can be set for lazy compilation.
185 class IsInLoop: public BitField<bool, 3, 1> {}; 188 class IsInLoop: public BitField<bool, 3, 1> {};
186 // Strict mode - used in eager compilation. 189 // Strict mode - used in eager compilation.
187 class IsStrictMode: public BitField<bool, 4, 1> {}; 190 class IsStrictMode: public BitField<bool, 4, 1> {};
188 // Native syntax (%-stuff) allowed? 191 // Is this a function from our natives.
189 class IsNativesSyntaxAllowed: public BitField<bool, 5, 1> {}; 192 class IsNative: public BitField<bool, 6, 1> {};
190 193
191 unsigned flags_; 194 unsigned flags_;
192 195
193 // Fields filled in by the compilation pipeline. 196 // Fields filled in by the compilation pipeline.
194 // AST filled in by the parser. 197 // AST filled in by the parser.
195 FunctionLiteral* function_; 198 FunctionLiteral* function_;
196 // The scope of the function literal as a convenience. Set to indicate 199 // The scope of the function literal as a convenience. Set to indicate
197 // that scopes have been analyzed. 200 // that scopes have been analyzed.
198 Scope* scope_; 201 Scope* scope_;
199 // The compiled code. 202 // The compiled code.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 isolate->frame_element_constant_list()->Clear(); 300 isolate->frame_element_constant_list()->Clear();
298 isolate->result_constant_list()->Clear(); 301 isolate->result_constant_list()->Clear();
299 } 302 }
300 } 303 }
301 }; 304 };
302 305
303 306
304 } } // namespace v8::internal 307 } } // namespace v8::internal
305 308
306 #endif // V8_COMPILER_H_ 309 #endif // V8_COMPILER_H_
OLDNEW
« no previous file with comments | « no previous file | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698