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

Side by Side Diff: src/compiler.h

Issue 16482004: Revert "Enable map dependency to in-flight compilation info." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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/arm/lithium-codegen-arm.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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 struct OffsetRange { 50 struct OffsetRange {
51 OffsetRange(int from, int to) : from(from), to(to) {} 51 OffsetRange(int from, int to) : from(from), to(to) {}
52 int from; 52 int from;
53 int to; 53 int to;
54 }; 54 };
55 55
56 // CompilationInfo encapsulates some information known at compile time. It 56 // CompilationInfo encapsulates some information known at compile time. It
57 // is constructed based on the resources available at compile-time. 57 // is constructed based on the resources available at compile-time.
58 class CompilationInfo { 58 class CompilationInfo {
59 public: 59 public:
60 CompilationInfo(Handle<Script> script, Zone* zone);
61 CompilationInfo(Handle<SharedFunctionInfo> shared_info, Zone* zone);
60 CompilationInfo(Handle<JSFunction> closure, Zone* zone); 62 CompilationInfo(Handle<JSFunction> closure, Zone* zone);
61 virtual ~CompilationInfo(); 63 CompilationInfo(HydrogenCodeStub* stub, Isolate* isolate, Zone* zone);
64
65 ~CompilationInfo();
62 66
63 Isolate* isolate() { 67 Isolate* isolate() {
64 ASSERT(Isolate::Current() == isolate_); 68 ASSERT(Isolate::Current() == isolate_);
65 return isolate_; 69 return isolate_;
66 } 70 }
67 Zone* zone() { return zone_; } 71 Zone* zone() { return zone_; }
68 bool is_lazy() const { return IsLazy::decode(flags_); } 72 bool is_lazy() const { return IsLazy::decode(flags_); }
69 bool is_eval() const { return IsEval::decode(flags_); } 73 bool is_eval() const { return IsEval::decode(flags_); }
70 bool is_global() const { return IsGlobal::decode(flags_); } 74 bool is_global() const { return IsGlobal::decode(flags_); }
71 bool is_classic_mode() const { return language_mode() == CLASSIC_MODE; } 75 bool is_classic_mode() const { return language_mode() == CLASSIC_MODE; }
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 236
233 // Disable all optimization attempts of this info for the rest of the 237 // Disable all optimization attempts of this info for the rest of the
234 // current compilation pipeline. 238 // current compilation pipeline.
235 void AbortOptimization(); 239 void AbortOptimization();
236 240
237 void set_deferred_handles(DeferredHandles* deferred_handles) { 241 void set_deferred_handles(DeferredHandles* deferred_handles) {
238 ASSERT(deferred_handles_ == NULL); 242 ASSERT(deferred_handles_ == NULL);
239 deferred_handles_ = deferred_handles; 243 deferred_handles_ = deferred_handles;
240 } 244 }
241 245
242 ZoneList<Handle<Map> >* dependent_maps(DependentCode::DependencyGroup group) {
243 if (dependent_maps_[group] == NULL) {
244 dependent_maps_[group] = new(zone_) ZoneList<Handle<Map> >(2, zone_);
245 }
246 return dependent_maps_[group];
247 }
248
249 void CommitDependentMaps(Handle<Code> code);
250
251 void RollbackDependentMaps();
252
253 void SaveHandles() { 246 void SaveHandles() {
254 SaveHandle(&closure_); 247 SaveHandle(&closure_);
255 SaveHandle(&shared_info_); 248 SaveHandle(&shared_info_);
256 SaveHandle(&context_); 249 SaveHandle(&context_);
257 SaveHandle(&script_); 250 SaveHandle(&script_);
258 } 251 }
259 252
260 const char* bailout_reason() const { return bailout_reason_; } 253 const char* bailout_reason() const { return bailout_reason_; }
261 void set_bailout_reason(const char* reason) { bailout_reason_ = reason; } 254 void set_bailout_reason(const char* reason) { bailout_reason_ = reason; }
262 255
(...skipping 13 matching lines...) Expand all
276 inline void AddNoFrameRange(int from, int to) { 269 inline void AddNoFrameRange(int from, int to) {
277 if (no_frame_ranges_) no_frame_ranges_->Add(OffsetRange(from, to)); 270 if (no_frame_ranges_) no_frame_ranges_->Add(OffsetRange(from, to));
278 } 271 }
279 272
280 List<OffsetRange>* ReleaseNoFrameRanges() { 273 List<OffsetRange>* ReleaseNoFrameRanges() {
281 List<OffsetRange>* result = no_frame_ranges_; 274 List<OffsetRange>* result = no_frame_ranges_;
282 no_frame_ranges_ = NULL; 275 no_frame_ranges_ = NULL;
283 return result; 276 return result;
284 } 277 }
285 278
286 Handle<Foreign> object_wrapper() {
287 if (object_wrapper_.is_null()) {
288 object_wrapper_ =
289 isolate()->factory()->NewForeign(reinterpret_cast<Address>(this));
290 }
291 return object_wrapper_;
292 }
293
294 void AbortDueToDependentMap() {
295 mode_ = DEPENDENT_MAP_ABORT;
296 }
297
298 bool HasAbortedDueToDependentMap() {
299 return mode_ == DEPENDENT_MAP_ABORT;
300 }
301
302 protected:
303 CompilationInfo(Handle<Script> script, Zone* zone);
304 CompilationInfo(Handle<SharedFunctionInfo> shared_info, Zone* zone);
305 CompilationInfo(HydrogenCodeStub* stub, Isolate* isolate, Zone* zone);
306 279
307 private: 280 private:
308 Isolate* isolate_; 281 Isolate* isolate_;
309 282
310 // Compilation mode. 283 // Compilation mode.
311 // BASE is generated by the full codegen, optionally prepared for bailouts. 284 // BASE is generated by the full codegen, optionally prepared for bailouts.
312 // OPTIMIZE is optimized code generated by the Hydrogen-based backend. 285 // OPTIMIZE is optimized code generated by the Hydrogen-based backend.
313 // NONOPT is generated by the full codegen and is not prepared for 286 // NONOPT is generated by the full codegen and is not prepared for
314 // recompilation/bailouts. These functions are never recompiled. 287 // recompilation/bailouts. These functions are never recompiled.
315 enum Mode { 288 enum Mode {
316 BASE, 289 BASE,
317 OPTIMIZE, 290 OPTIMIZE,
318 NONOPT, 291 NONOPT,
319 STUB, 292 STUB
320 DEPENDENT_MAP_ABORT
321 }; 293 };
322 294
323 void Initialize(Isolate* isolate, Mode mode, Zone* zone); 295 void Initialize(Isolate* isolate, Mode mode, Zone* zone);
324 296
325 void SetMode(Mode mode) { 297 void SetMode(Mode mode) {
326 ASSERT(V8::UseCrankshaft()); 298 ASSERT(V8::UseCrankshaft());
327 mode_ = mode; 299 mode_ = mode;
328 } 300 }
329 301
330 // Flags using template class BitField<type, start, length>. All are 302 // Flags using template class BitField<type, start, length>. All are
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 // Compilation mode flag and whether deoptimization is allowed. 362 // Compilation mode flag and whether deoptimization is allowed.
391 Mode mode_; 363 Mode mode_;
392 BailoutId osr_ast_id_; 364 BailoutId osr_ast_id_;
393 365
394 // The zone from which the compilation pipeline working on this 366 // The zone from which the compilation pipeline working on this
395 // CompilationInfo allocates. 367 // CompilationInfo allocates.
396 Zone* zone_; 368 Zone* zone_;
397 369
398 DeferredHandles* deferred_handles_; 370 DeferredHandles* deferred_handles_;
399 371
400 ZoneList<Handle<Map> >* dependent_maps_[DependentCode::kGroupCount];
401
402 template<typename T> 372 template<typename T>
403 void SaveHandle(Handle<T> *object) { 373 void SaveHandle(Handle<T> *object) {
404 if (!object->is_null()) { 374 if (!object->is_null()) {
405 Handle<T> handle(*(*object)); 375 Handle<T> handle(*(*object));
406 *object = handle; 376 *object = handle;
407 } 377 }
408 } 378 }
409 379
410 const char* bailout_reason_; 380 const char* bailout_reason_;
411 381
412 int prologue_offset_; 382 int prologue_offset_;
413 383
414 List<OffsetRange>* no_frame_ranges_; 384 List<OffsetRange>* no_frame_ranges_;
415 385
416 // A copy of shared_info()->opt_count() to avoid handle deref 386 // A copy of shared_info()->opt_count() to avoid handle deref
417 // during graph optimization. 387 // during graph optimization.
418 int opt_count_; 388 int opt_count_;
419 389
420 Handle<Foreign> object_wrapper_;
421
422 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); 390 DISALLOW_COPY_AND_ASSIGN(CompilationInfo);
423 }; 391 };
424 392
425 393
426 // Exactly like a CompilationInfo, except also creates and enters a 394 // Exactly like a CompilationInfo, except also creates and enters a
427 // Zone on construction and deallocates it on exit. 395 // Zone on construction and deallocates it on exit.
428 class CompilationInfoWithZone: public CompilationInfo { 396 class CompilationInfoWithZone: public CompilationInfo {
429 public: 397 public:
430 explicit CompilationInfoWithZone(Handle<Script> script) 398 explicit CompilationInfoWithZone(Handle<Script> script)
431 : CompilationInfo(script, &zone_), 399 : CompilationInfo(script, &zone_),
432 zone_(script->GetIsolate()), 400 zone_(script->GetIsolate()),
433 zone_scope_(&zone_, DELETE_ON_EXIT) {} 401 zone_scope_(&zone_, DELETE_ON_EXIT) {}
434 explicit CompilationInfoWithZone(Handle<SharedFunctionInfo> shared_info) 402 explicit CompilationInfoWithZone(Handle<SharedFunctionInfo> shared_info)
435 : CompilationInfo(shared_info, &zone_), 403 : CompilationInfo(shared_info, &zone_),
436 zone_(shared_info->GetIsolate()), 404 zone_(shared_info->GetIsolate()),
437 zone_scope_(&zone_, DELETE_ON_EXIT) {} 405 zone_scope_(&zone_, DELETE_ON_EXIT) {}
438 explicit CompilationInfoWithZone(Handle<JSFunction> closure) 406 explicit CompilationInfoWithZone(Handle<JSFunction> closure)
439 : CompilationInfo(closure, &zone_), 407 : CompilationInfo(closure, &zone_),
440 zone_(closure->GetIsolate()), 408 zone_(closure->GetIsolate()),
441 zone_scope_(&zone_, DELETE_ON_EXIT) {} 409 zone_scope_(&zone_, DELETE_ON_EXIT) {}
442 CompilationInfoWithZone(HydrogenCodeStub* stub, Isolate* isolate) 410 explicit CompilationInfoWithZone(HydrogenCodeStub* stub, Isolate* isolate)
443 : CompilationInfo(stub, isolate, &zone_), 411 : CompilationInfo(stub, isolate, &zone_),
444 zone_(isolate), 412 zone_(isolate),
445 zone_scope_(&zone_, DELETE_ON_EXIT) {} 413 zone_scope_(&zone_, DELETE_ON_EXIT) {}
446 414
447 // Virtual destructor because a CompilationInfoWithZone has to exit the
448 // zone scope and get rid of dependent maps even when the destructor is
449 // called when cast as a CompilationInfo.
450 virtual ~CompilationInfoWithZone() {
451 RollbackDependentMaps();
452 }
453
454 private: 415 private:
455 Zone zone_; 416 Zone zone_;
456 ZoneScope zone_scope_; 417 ZoneScope zone_scope_;
457 }; 418 };
458 419
459 420
460 // A wrapper around a CompilationInfo that detaches the Handles from 421 // A wrapper around a CompilationInfo that detaches the Handles from
461 // the underlying DeferredHandleScope and stores them in info_ on 422 // the underlying DeferredHandleScope and stores them in info_ on
462 // destruction. 423 // destruction.
463 class CompilationHandleScope BASE_EMBEDDED { 424 class CompilationHandleScope BASE_EMBEDDED {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 574
614 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, 575 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag,
615 CompilationInfo* info, 576 CompilationInfo* info,
616 Handle<SharedFunctionInfo> shared); 577 Handle<SharedFunctionInfo> shared);
617 }; 578 };
618 579
619 580
620 } } // namespace v8::internal 581 } } // namespace v8::internal
621 582
622 #endif // V8_COMPILER_H_ 583 #endif // V8_COMPILER_H_
OLDNEW
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698