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

Side by Side Diff: src/compiler.h

Issue 10640012: Add a second kind of HandleScope that ties the lifetime of Handles created in its scope to the life… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix nits. Created 8 years, 5 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/api.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 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 27 matching lines...) Expand all
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 CompilationInfo(Handle<Script> script, Zone* zone); 44 CompilationInfo(Handle<Script> script, Zone* zone);
45 CompilationInfo(Handle<SharedFunctionInfo> shared_info, Zone* zone); 45 CompilationInfo(Handle<SharedFunctionInfo> shared_info, Zone* zone);
46 CompilationInfo(Handle<JSFunction> closure, Zone* zone); 46 CompilationInfo(Handle<JSFunction> closure, Zone* zone);
47 47
48 ~CompilationInfo();
49
48 Isolate* isolate() { 50 Isolate* isolate() {
49 ASSERT(Isolate::Current() == isolate_); 51 ASSERT(Isolate::Current() == isolate_);
50 return isolate_; 52 return isolate_;
51 } 53 }
52 Zone* zone() { 54 Zone* zone() {
53 return zone_; 55 return zone_;
54 } 56 }
55 bool is_lazy() const { return IsLazy::decode(flags_); } 57 bool is_lazy() const { return IsLazy::decode(flags_); }
56 bool is_eval() const { return IsEval::decode(flags_); } 58 bool is_eval() const { return IsEval::decode(flags_); }
57 bool is_global() const { return IsGlobal::decode(flags_); } 59 bool is_global() const { return IsGlobal::decode(flags_); }
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 flags_ |= SupportsDeoptimization::encode(true); 168 flags_ |= SupportsDeoptimization::encode(true);
167 } 169 }
168 170
169 // Determines whether or not to insert a self-optimization header. 171 // Determines whether or not to insert a self-optimization header.
170 bool ShouldSelfOptimize(); 172 bool ShouldSelfOptimize();
171 173
172 // Disable all optimization attempts of this info for the rest of the 174 // Disable all optimization attempts of this info for the rest of the
173 // current compilation pipeline. 175 // current compilation pipeline.
174 void AbortOptimization(); 176 void AbortOptimization();
175 177
178 void set_deferred_handles(DeferredHandles* deferred_handles) {
179 ASSERT(deferred_handles_ == NULL);
180 deferred_handles_ = deferred_handles;
181 }
182
176 private: 183 private:
177 Isolate* isolate_; 184 Isolate* isolate_;
178 185
179 // Compilation mode. 186 // Compilation mode.
180 // BASE is generated by the full codegen, optionally prepared for bailouts. 187 // BASE is generated by the full codegen, optionally prepared for bailouts.
181 // OPTIMIZE is optimized code generated by the Hydrogen-based backend. 188 // OPTIMIZE is optimized code generated by the Hydrogen-based backend.
182 // NONOPT is generated by the full codegen and is not prepared for 189 // NONOPT is generated by the full codegen and is not prepared for
183 // recompilation/bailouts. These functions are never recompiled. 190 // recompilation/bailouts. These functions are never recompiled.
184 enum Mode { 191 enum Mode {
185 BASE, 192 BASE,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 Handle<Context> calling_context_; 259 Handle<Context> calling_context_;
253 260
254 // Compilation mode flag and whether deoptimization is allowed. 261 // Compilation mode flag and whether deoptimization is allowed.
255 Mode mode_; 262 Mode mode_;
256 int osr_ast_id_; 263 int osr_ast_id_;
257 264
258 // The zone from which the compilation pipeline working on this 265 // The zone from which the compilation pipeline working on this
259 // CompilationInfo allocates. 266 // CompilationInfo allocates.
260 Zone* zone_; 267 Zone* zone_;
261 268
269 DeferredHandles* deferred_handles_;
270
262 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); 271 DISALLOW_COPY_AND_ASSIGN(CompilationInfo);
263 }; 272 };
264 273
265 274
266 // Exactly like a CompilationInfo, except also creates and enters a 275 // Exactly like a CompilationInfo, except also creates and enters a
267 // Zone on construction and deallocates it on exit. 276 // Zone on construction and deallocates it on exit.
268 class CompilationInfoWithZone: public CompilationInfo { 277 class CompilationInfoWithZone: public CompilationInfo {
269 public: 278 public:
270 explicit CompilationInfoWithZone(Handle<Script> script) 279 explicit CompilationInfoWithZone(Handle<Script> script)
271 : CompilationInfo(script, &zone_), 280 : CompilationInfo(script, &zone_),
272 zone_(script->GetIsolate()), 281 zone_(script->GetIsolate()),
273 zone_scope_(&zone_, DELETE_ON_EXIT) {} 282 zone_scope_(&zone_, DELETE_ON_EXIT) {}
274 explicit CompilationInfoWithZone(Handle<SharedFunctionInfo> shared_info) 283 explicit CompilationInfoWithZone(Handle<SharedFunctionInfo> shared_info)
275 : CompilationInfo(shared_info, &zone_), 284 : CompilationInfo(shared_info, &zone_),
276 zone_(shared_info->GetIsolate()), 285 zone_(shared_info->GetIsolate()),
277 zone_scope_(&zone_, DELETE_ON_EXIT) {} 286 zone_scope_(&zone_, DELETE_ON_EXIT) {}
278 explicit CompilationInfoWithZone(Handle<JSFunction> closure) 287 explicit CompilationInfoWithZone(Handle<JSFunction> closure)
279 : CompilationInfo(closure, &zone_), 288 : CompilationInfo(closure, &zone_),
280 zone_(closure->GetIsolate()), 289 zone_(closure->GetIsolate()),
281 zone_scope_(&zone_, DELETE_ON_EXIT) {} 290 zone_scope_(&zone_, DELETE_ON_EXIT) {}
282 291
283 private: 292 private:
284 Zone zone_; 293 Zone zone_;
285 ZoneScope zone_scope_; 294 ZoneScope zone_scope_;
286 }; 295 };
287 296
288 297
298 // A wrapper around a CompilationInfo that detaches the Handles from
299 // the underlying DeferredHandleScope and stores them in info_ on
300 // destruction.
301 class CompilationHandleScope BASE_EMBEDDED {
302 public:
303 explicit CompilationHandleScope(CompilationInfo* info)
304 : deferred_(info->isolate()), info_(info) {}
305 ~CompilationHandleScope() {
306 info_->set_deferred_handles(deferred_.Detach());
307 }
308
309 private:
310 DeferredHandleScope deferred_;
311 CompilationInfo* info_;
312 };
313
314
289 // The V8 compiler 315 // The V8 compiler
290 // 316 //
291 // General strategy: Source code is translated into an anonymous function w/o 317 // General strategy: Source code is translated into an anonymous function w/o
292 // parameters which then can be executed. If the source code contains other 318 // parameters which then can be executed. If the source code contains other
293 // functions, they will be compiled and allocated as part of the compilation 319 // functions, they will be compiled and allocated as part of the compilation
294 // of the source code. 320 // of the source code.
295 321
296 // Please note this interface returns shared function infos. This means you 322 // Please note this interface returns shared function infos. This means you
297 // need to call Factory::NewFunctionFromSharedFunctionInfo before you have a 323 // need to call Factory::NewFunctionFromSharedFunctionInfo before you have a
298 // real function with a context. 324 // real function with a context.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 376
351 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, 377 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag,
352 CompilationInfo* info, 378 CompilationInfo* info,
353 Handle<SharedFunctionInfo> shared); 379 Handle<SharedFunctionInfo> shared);
354 }; 380 };
355 381
356 382
357 } } // namespace v8::internal 383 } } // namespace v8::internal
358 384
359 #endif // V8_COMPILER_H_ 385 #endif // V8_COMPILER_H_
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698