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

Side by Side Diff: src/compiler.h

Issue 10534139: One Zone per CompilationInfo. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rename CompilationInfoZone to ZoneWithCompilationInfo Created 8 years, 6 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.h ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 23 matching lines...) Expand all
34 34
35 namespace v8 { 35 namespace v8 {
36 namespace internal { 36 namespace internal {
37 37
38 class ScriptDataImpl; 38 class ScriptDataImpl;
39 39
40 // CompilationInfo encapsulates some information known at compile time. It 40 // CompilationInfo encapsulates some information known at compile time. It
41 // is constructed based on the resources available at compile-time. 41 // is constructed based on the resources available at compile-time.
42 class CompilationInfo BASE_EMBEDDED { 42 class CompilationInfo BASE_EMBEDDED {
43 public: 43 public:
44 explicit CompilationInfo(Handle<Script> script); 44 CompilationInfo(Handle<Script> script, Zone* zone);
45 explicit CompilationInfo(Handle<SharedFunctionInfo> shared_info); 45 CompilationInfo(Handle<SharedFunctionInfo> shared_info, Zone* zone);
46 explicit CompilationInfo(Handle<JSFunction> closure); 46 CompilationInfo(Handle<JSFunction> closure, Zone* zone);
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 Zone* zone() {
53 return zone_;
54 }
52 bool is_lazy() const { return IsLazy::decode(flags_); } 55 bool is_lazy() const { return IsLazy::decode(flags_); }
53 bool is_eval() const { return IsEval::decode(flags_); } 56 bool is_eval() const { return IsEval::decode(flags_); }
54 bool is_global() const { return IsGlobal::decode(flags_); } 57 bool is_global() const { return IsGlobal::decode(flags_); }
55 bool is_classic_mode() const { return language_mode() == CLASSIC_MODE; } 58 bool is_classic_mode() const { return language_mode() == CLASSIC_MODE; }
56 bool is_extended_mode() const { return language_mode() == EXTENDED_MODE; } 59 bool is_extended_mode() const { return language_mode() == EXTENDED_MODE; }
57 LanguageMode language_mode() const { 60 LanguageMode language_mode() const {
58 return LanguageModeField::decode(flags_); 61 return LanguageModeField::decode(flags_);
59 } 62 }
60 bool is_in_loop() const { return IsInLoop::decode(flags_); } 63 bool is_in_loop() const { return IsInLoop::decode(flags_); }
61 FunctionLiteral* function() const { return function_; } 64 FunctionLiteral* function() const { return function_; }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // BASE is generated by the full codegen, optionally prepared for bailouts. 180 // BASE is generated by the full codegen, optionally prepared for bailouts.
178 // OPTIMIZE is optimized code generated by the Hydrogen-based backend. 181 // OPTIMIZE is optimized code generated by the Hydrogen-based backend.
179 // NONOPT is generated by the full codegen and is not prepared for 182 // NONOPT is generated by the full codegen and is not prepared for
180 // recompilation/bailouts. These functions are never recompiled. 183 // recompilation/bailouts. These functions are never recompiled.
181 enum Mode { 184 enum Mode {
182 BASE, 185 BASE,
183 OPTIMIZE, 186 OPTIMIZE,
184 NONOPT 187 NONOPT
185 }; 188 };
186 189
187 CompilationInfo() : function_(NULL) {}
188
189 void Initialize(Mode mode) { 190 void Initialize(Mode mode) {
190 mode_ = V8::UseCrankshaft() ? mode : NONOPT; 191 mode_ = V8::UseCrankshaft() ? mode : NONOPT;
191 ASSERT(!script_.is_null()); 192 ASSERT(!script_.is_null());
192 if (script_->type()->value() == Script::TYPE_NATIVE) { 193 if (script_->type()->value() == Script::TYPE_NATIVE) {
193 MarkAsNative(); 194 MarkAsNative();
194 } 195 }
195 if (!shared_info_.is_null()) { 196 if (!shared_info_.is_null()) {
196 ASSERT(language_mode() == CLASSIC_MODE); 197 ASSERT(language_mode() == CLASSIC_MODE);
197 SetLanguageMode(shared_info_->language_mode()); 198 SetLanguageMode(shared_info_->language_mode());
198 } 199 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 ScriptDataImpl* pre_parse_data_; 248 ScriptDataImpl* pre_parse_data_;
248 249
249 // The context of the caller is needed for eval code, and will be a null 250 // The context of the caller is needed for eval code, and will be a null
250 // handle otherwise. 251 // handle otherwise.
251 Handle<Context> calling_context_; 252 Handle<Context> calling_context_;
252 253
253 // Compilation mode flag and whether deoptimization is allowed. 254 // Compilation mode flag and whether deoptimization is allowed.
254 Mode mode_; 255 Mode mode_;
255 int osr_ast_id_; 256 int osr_ast_id_;
256 257
258 // The zone from which the compilation pipeline working on this
259 // CompilationInfo allocates.
260 Zone* zone_;
261
257 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); 262 DISALLOW_COPY_AND_ASSIGN(CompilationInfo);
258 }; 263 };
259 264
260 265
266 // Exactly like a CompilationInfo, except also creates and enters a
267 // Zone on construction and deallocates it on exit.
268 class CompilationInfoWithZone: public CompilationInfo {
269 public:
270 explicit CompilationInfoWithZone(Handle<Script> script)
271 : CompilationInfo(script, &zone_),
272 zone_(script->GetIsolate()),
273 zone_scope_(&zone_, DELETE_ON_EXIT) {}
274 explicit CompilationInfoWithZone(Handle<SharedFunctionInfo> shared_info)
275 : CompilationInfo(shared_info, &zone_),
276 zone_(shared_info->GetIsolate()),
277 zone_scope_(&zone_, DELETE_ON_EXIT) {}
278 explicit CompilationInfoWithZone(Handle<JSFunction> closure)
279 : CompilationInfo(closure, &zone_),
280 zone_(closure->GetIsolate()),
281 zone_scope_(&zone_, DELETE_ON_EXIT) {}
282
283 private:
284 Zone zone_;
285 ZoneScope zone_scope_;
286 };
287
288
261 // The V8 compiler 289 // The V8 compiler
262 // 290 //
263 // General strategy: Source code is translated into an anonymous function w/o 291 // General strategy: Source code is translated into an anonymous function w/o
264 // parameters which then can be executed. If the source code contains other 292 // parameters which then can be executed. If the source code contains other
265 // functions, they will be compiled and allocated as part of the compilation 293 // functions, they will be compiled and allocated as part of the compilation
266 // of the source code. 294 // of the source code.
267 295
268 // Please note this interface returns shared function infos. This means you 296 // Please note this interface returns shared function infos. This means you
269 // need to call Factory::NewFunctionFromSharedFunctionInfo before you have a 297 // need to call Factory::NewFunctionFromSharedFunctionInfo before you have a
270 // real function with a context. 298 // real function with a context.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 350
323 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, 351 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag,
324 CompilationInfo* info, 352 CompilationInfo* info,
325 Handle<SharedFunctionInfo> shared); 353 Handle<SharedFunctionInfo> shared);
326 }; 354 };
327 355
328 356
329 } } // namespace v8::internal 357 } } // namespace v8::internal
330 358
331 #endif // V8_COMPILER_H_ 359 #endif // V8_COMPILER_H_
OLDNEW
« no previous file with comments | « src/ast.h ('k') | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698