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

Side by Side Diff: src/compiler.h

Issue 6286043: Direct call to eval passes strict mode through. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Code review feedback. Created 9 years, 10 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/compilation-cache.cc ('k') | 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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // is constructed based on the resources available at compile-time. 42 // is constructed based on the resources available at compile-time.
43 class CompilationInfo BASE_EMBEDDED { 43 class CompilationInfo BASE_EMBEDDED {
44 public: 44 public:
45 explicit CompilationInfo(Handle<Script> script); 45 explicit CompilationInfo(Handle<Script> script);
46 explicit CompilationInfo(Handle<SharedFunctionInfo> shared_info); 46 explicit CompilationInfo(Handle<SharedFunctionInfo> shared_info);
47 explicit CompilationInfo(Handle<JSFunction> closure); 47 explicit CompilationInfo(Handle<JSFunction> closure);
48 48
49 bool is_lazy() const { return (flags_ & IsLazy::mask()) != 0; } 49 bool is_lazy() const { return (flags_ & IsLazy::mask()) != 0; }
50 bool is_eval() const { return (flags_ & IsEval::mask()) != 0; } 50 bool is_eval() const { return (flags_ & IsEval::mask()) != 0; }
51 bool is_global() const { return (flags_ & IsGlobal::mask()) != 0; } 51 bool is_global() const { return (flags_ & IsGlobal::mask()) != 0; }
52 bool is_strict() const { return (flags_ & IsStrict::mask()) != 0; }
52 bool is_in_loop() const { return (flags_ & IsInLoop::mask()) != 0; } 53 bool is_in_loop() const { return (flags_ & IsInLoop::mask()) != 0; }
53 FunctionLiteral* function() const { return function_; } 54 FunctionLiteral* function() const { return function_; }
54 Scope* scope() const { return scope_; } 55 Scope* scope() const { return scope_; }
55 Handle<Code> code() const { return code_; } 56 Handle<Code> code() const { return code_; }
56 Handle<JSFunction> closure() const { return closure_; } 57 Handle<JSFunction> closure() const { return closure_; }
57 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } 58 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; }
58 Handle<Script> script() const { return script_; } 59 Handle<Script> script() const { return script_; }
59 v8::Extension* extension() const { return extension_; } 60 v8::Extension* extension() const { return extension_; }
60 ScriptDataImpl* pre_parse_data() const { return pre_parse_data_; } 61 ScriptDataImpl* pre_parse_data() const { return pre_parse_data_; }
61 Handle<Context> calling_context() const { return calling_context_; } 62 Handle<Context> calling_context() const { return calling_context_; }
62 int osr_ast_id() const { return osr_ast_id_; } 63 int osr_ast_id() const { return osr_ast_id_; }
63 64
64 void MarkAsEval() { 65 void MarkAsEval() {
65 ASSERT(!is_lazy()); 66 ASSERT(!is_lazy());
66 flags_ |= IsEval::encode(true); 67 flags_ |= IsEval::encode(true);
67 } 68 }
68 void MarkAsGlobal() { 69 void MarkAsGlobal() {
69 ASSERT(!is_lazy()); 70 ASSERT(!is_lazy());
70 flags_ |= IsGlobal::encode(true); 71 flags_ |= IsGlobal::encode(true);
71 } 72 }
73 void MarkAsStrict() {
74 ASSERT(!is_lazy());
75 flags_ |= IsStrict::encode(true);
76 }
72 void MarkAsInLoop() { 77 void MarkAsInLoop() {
73 ASSERT(is_lazy()); 78 ASSERT(is_lazy());
74 flags_ |= IsInLoop::encode(true); 79 flags_ |= IsInLoop::encode(true);
75 } 80 }
76 void SetFunction(FunctionLiteral* literal) { 81 void SetFunction(FunctionLiteral* literal) {
77 ASSERT(function_ == NULL); 82 ASSERT(function_ == NULL);
78 function_ = literal; 83 function_ = literal;
79 } 84 }
80 void SetScope(Scope* scope) { 85 void SetScope(Scope* scope) {
81 ASSERT(scope_ == NULL); 86 ASSERT(scope_ == NULL);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 // Flags using template class BitField<type, start, length>. All are 160 // Flags using template class BitField<type, start, length>. All are
156 // false by default. 161 // false by default.
157 // 162 //
158 // Compilation is either eager or lazy. 163 // Compilation is either eager or lazy.
159 class IsLazy: public BitField<bool, 0, 1> {}; 164 class IsLazy: public BitField<bool, 0, 1> {};
160 // Flags that can be set for eager compilation. 165 // Flags that can be set for eager compilation.
161 class IsEval: public BitField<bool, 1, 1> {}; 166 class IsEval: public BitField<bool, 1, 1> {};
162 class IsGlobal: public BitField<bool, 2, 1> {}; 167 class IsGlobal: public BitField<bool, 2, 1> {};
163 // Flags that can be set for lazy compilation. 168 // Flags that can be set for lazy compilation.
164 class IsInLoop: public BitField<bool, 3, 1> {}; 169 class IsInLoop: public BitField<bool, 3, 1> {};
170 // Strict mode - used in eager compilation.
171 class IsStrict: public BitField<bool, 4, 1> {};
165 172
166 unsigned flags_; 173 unsigned flags_;
167 174
168 // Fields filled in by the compilation pipeline. 175 // Fields filled in by the compilation pipeline.
169 // AST filled in by the parser. 176 // AST filled in by the parser.
170 FunctionLiteral* function_; 177 FunctionLiteral* function_;
171 // The scope of the function literal as a convenience. Set to indicate 178 // The scope of the function literal as a convenience. Set to indicate
172 // that scopes have been analyzed. 179 // that scopes have been analyzed.
173 Scope* scope_; 180 Scope* scope_;
174 // The compiled code. 181 // The compiled code.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 int line_offset, 230 int line_offset,
224 int column_offset, 231 int column_offset,
225 v8::Extension* extension, 232 v8::Extension* extension,
226 ScriptDataImpl* pre_data, 233 ScriptDataImpl* pre_data,
227 Handle<Object> script_data, 234 Handle<Object> script_data,
228 NativesFlag is_natives_code); 235 NativesFlag is_natives_code);
229 236
230 // Compile a String source within a context for Eval. 237 // Compile a String source within a context for Eval.
231 static Handle<SharedFunctionInfo> CompileEval(Handle<String> source, 238 static Handle<SharedFunctionInfo> CompileEval(Handle<String> source,
232 Handle<Context> context, 239 Handle<Context> context,
233 bool is_global); 240 bool is_global,
241 StrictModeFlag strict_mode);
234 242
235 // Compile from function info (used for lazy compilation). Returns true on 243 // Compile from function info (used for lazy compilation). Returns true on
236 // success and false if the compilation resulted in a stack overflow. 244 // success and false if the compilation resulted in a stack overflow.
237 static bool CompileLazy(CompilationInfo* info); 245 static bool CompileLazy(CompilationInfo* info);
238 246
239 // Compile a shared function info object (the function is possibly lazily 247 // Compile a shared function info object (the function is possibly lazily
240 // compiled). 248 // compiled).
241 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node, 249 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node,
242 Handle<Script> script); 250 Handle<Script> script);
243 251
(...skipping 25 matching lines...) Expand all
269 FrameElement::ClearConstantList(); 277 FrameElement::ClearConstantList();
270 Result::ClearConstantList(); 278 Result::ClearConstantList();
271 } 279 }
272 } 280 }
273 }; 281 };
274 282
275 283
276 } } // namespace v8::internal 284 } } // namespace v8::internal
277 285
278 #endif // V8_COMPILER_H_ 286 #endif // V8_COMPILER_H_
OLDNEW
« no previous file with comments | « src/compilation-cache.cc ('k') | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698