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

Side by Side Diff: src/compiler.h

Issue 8344082: Replace boolean indications of strict mode by an enum value. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Some fixes and adapted the preparser. 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 | « src/ast-inl.h ('k') | src/compiler.cc » ('j') | src/compiler.cc » ('J')
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 explicit CompilationInfo(Handle<SharedFunctionInfo> shared_info); 45 explicit CompilationInfo(Handle<SharedFunctionInfo> shared_info);
46 explicit CompilationInfo(Handle<JSFunction> closure); 46 explicit CompilationInfo(Handle<JSFunction> closure);
47 47
48 Isolate* isolate() { 48 Isolate* isolate() {
49 ASSERT(Isolate::Current() == isolate_); 49 ASSERT(Isolate::Current() == isolate_);
50 return isolate_; 50 return isolate_;
51 } 51 }
52 bool is_lazy() const { return IsLazy::decode(flags_); } 52 bool is_lazy() const { return IsLazy::decode(flags_); }
53 bool is_eval() const { return IsEval::decode(flags_); } 53 bool is_eval() const { return IsEval::decode(flags_); }
54 bool is_global() const { return IsGlobal::decode(flags_); } 54 bool is_global() const { return IsGlobal::decode(flags_); }
55 bool is_strict_mode() const { return IsStrictMode::decode(flags_); } 55 bool is_strict_mode() const { return strict_mode_flag() == kStrictMode; }
56 StrictModeFlag strict_mode_flag() const {
57 return StrictModeFlagField::decode(flags_);
58 }
56 bool is_in_loop() const { return IsInLoop::decode(flags_); } 59 bool is_in_loop() const { return IsInLoop::decode(flags_); }
57 FunctionLiteral* function() const { return function_; } 60 FunctionLiteral* function() const { return function_; }
58 Scope* scope() const { return scope_; } 61 Scope* scope() const { return scope_; }
59 Handle<Code> code() const { return code_; } 62 Handle<Code> code() const { return code_; }
60 Handle<JSFunction> closure() const { return closure_; } 63 Handle<JSFunction> closure() const { return closure_; }
61 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } 64 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; }
62 Handle<Script> script() const { return script_; } 65 Handle<Script> script() const { return script_; }
63 v8::Extension* extension() const { return extension_; } 66 v8::Extension* extension() const { return extension_; }
64 ScriptDataImpl* pre_parse_data() const { return pre_parse_data_; } 67 ScriptDataImpl* pre_parse_data() const { return pre_parse_data_; }
65 Handle<Context> calling_context() const { return calling_context_; } 68 Handle<Context> calling_context() const { return calling_context_; }
66 int osr_ast_id() const { return osr_ast_id_; } 69 int osr_ast_id() const { return osr_ast_id_; }
67 70
68 void MarkAsEval() { 71 void MarkAsEval() {
69 ASSERT(!is_lazy()); 72 ASSERT(!is_lazy());
70 flags_ |= IsEval::encode(true); 73 flags_ |= IsEval::encode(true);
71 } 74 }
72 void MarkAsGlobal() { 75 void MarkAsGlobal() {
73 ASSERT(!is_lazy()); 76 ASSERT(!is_lazy());
74 flags_ |= IsGlobal::encode(true); 77 flags_ |= IsGlobal::encode(true);
75 } 78 }
76 void MarkAsStrictMode() { 79 void SetStrictModeFlag(StrictModeFlag strict_mode_flag) {
77 flags_ |= IsStrictMode::encode(true); 80 ASSERT(StrictModeFlagField::decode(flags_) == kNonStrictMode ||
78 } 81 StrictModeFlagField::decode(flags_) == strict_mode_flag);
79 StrictModeFlag StrictMode() { 82 flags_ = StrictModeFlagField::update(flags_, strict_mode_flag);
80 return is_strict_mode() ? kStrictMode : kNonStrictMode;
81 } 83 }
82 void MarkAsInLoop() { 84 void MarkAsInLoop() {
83 ASSERT(is_lazy()); 85 ASSERT(is_lazy());
84 flags_ |= IsInLoop::encode(true); 86 flags_ |= IsInLoop::encode(true);
85 } 87 }
86 void MarkAsNative() { 88 void MarkAsNative() {
87 flags_ |= IsNative::encode(true); 89 flags_ |= IsNative::encode(true);
88 } 90 }
89 bool is_native() const { 91 bool is_native() const {
90 return IsNative::decode(flags_); 92 return IsNative::decode(flags_);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 }; 181 };
180 182
181 CompilationInfo() : function_(NULL) {} 183 CompilationInfo() : function_(NULL) {}
182 184
183 void Initialize(Mode mode) { 185 void Initialize(Mode mode) {
184 mode_ = V8::UseCrankshaft() ? mode : NONOPT; 186 mode_ = V8::UseCrankshaft() ? mode : NONOPT;
185 ASSERT(!script_.is_null()); 187 ASSERT(!script_.is_null());
186 if (script_->type()->value() == Script::TYPE_NATIVE) { 188 if (script_->type()->value() == Script::TYPE_NATIVE) {
187 MarkAsNative(); 189 MarkAsNative();
188 } 190 }
189 if (!shared_info_.is_null() && shared_info_->strict_mode()) { 191 if (!shared_info_.is_null()) {
190 MarkAsStrictMode(); 192 ASSERT(strict_mode_flag() == kNonStrictMode);
193 SetStrictModeFlag(shared_info_->strict_mode_flag());
191 } 194 }
192 } 195 }
193 196
194 void SetMode(Mode mode) { 197 void SetMode(Mode mode) {
195 ASSERT(V8::UseCrankshaft()); 198 ASSERT(V8::UseCrankshaft());
196 mode_ = mode; 199 mode_ = mode;
197 } 200 }
198 201
199 // Flags using template class BitField<type, start, length>. All are 202 // Flags using template class BitField<type, start, length>. All are
200 // false by default. 203 // false by default.
201 // 204 //
202 // Compilation is either eager or lazy. 205 // Compilation is either eager or lazy.
203 class IsLazy: public BitField<bool, 0, 1> {}; 206 class IsLazy: public BitField<bool, 0, 1> {};
204 // Flags that can be set for eager compilation. 207 // Flags that can be set for eager compilation.
205 class IsEval: public BitField<bool, 1, 1> {}; 208 class IsEval: public BitField<bool, 1, 1> {};
206 class IsGlobal: public BitField<bool, 2, 1> {}; 209 class IsGlobal: public BitField<bool, 2, 1> {};
207 // Flags that can be set for lazy compilation. 210 // Flags that can be set for lazy compilation.
208 class IsInLoop: public BitField<bool, 3, 1> {}; 211 class IsInLoop: public BitField<bool, 3, 1> {};
209 // Strict mode - used in eager compilation. 212 // Strict mode - used in eager compilation.
210 class IsStrictMode: public BitField<bool, 4, 1> {}; 213 class StrictModeFlagField: public BitField<StrictModeFlag, 4, 1> {};
211 // Is this a function from our natives. 214 // Is this a function from our natives.
212 class IsNative: public BitField<bool, 6, 1> {}; 215 class IsNative: public BitField<bool, 6, 1> {};
213 // Is this code being compiled with support for deoptimization.. 216 // Is this code being compiled with support for deoptimization..
214 class SupportsDeoptimization: public BitField<bool, 7, 1> {}; 217 class SupportsDeoptimization: public BitField<bool, 7, 1> {};
215 // If compiling for debugging produce just full code matching the 218 // If compiling for debugging produce just full code matching the
216 // initial mode setting. 219 // initial mode setting.
217 class IsCompilingForDebugging: public BitField<bool, 8, 1> {}; 220 class IsCompilingForDebugging: public BitField<bool, 8, 1> {};
218 221
219 222
220 unsigned flags_; 223 unsigned flags_;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 312
310 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, 313 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag,
311 CompilationInfo* info, 314 CompilationInfo* info,
312 Handle<SharedFunctionInfo> shared); 315 Handle<SharedFunctionInfo> shared);
313 }; 316 };
314 317
315 318
316 } } // namespace v8::internal 319 } } // namespace v8::internal
317 320
318 #endif // V8_COMPILER_H_ 321 #endif // V8_COMPILER_H_
OLDNEW
« no previous file with comments | « src/ast-inl.h ('k') | src/compiler.cc » ('j') | src/compiler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698