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

Side by Side Diff: src/api.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: 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 | « no previous file | src/api.cc » ('j') | src/api.cc » ('J')
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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 // so that the currently executing thread always has its own copy of this 402 // so that the currently executing thread always has its own copy of this
403 // data. 403 // data.
404 class HandleScopeImplementer { 404 class HandleScopeImplementer {
405 public: 405 public:
406 explicit HandleScopeImplementer(Isolate* isolate) 406 explicit HandleScopeImplementer(Isolate* isolate)
407 : isolate_(isolate), 407 : isolate_(isolate),
408 blocks_(0), 408 blocks_(0),
409 entered_contexts_(0), 409 entered_contexts_(0),
410 saved_contexts_(0), 410 saved_contexts_(0),
411 spare_(NULL), 411 spare_(NULL),
412 call_depth_(0) { } 412 call_depth_(0),
413 last_block_before_compilation_(NULL),
414 last_valid_handle_before_compilation_(NULL),
415 hidden_extensions_head_(NULL) { }
Erik Corry 2012/06/22 11:08:36 Instead of 'hidden' may I suggest 'persistent'. T
sanjoy 2012/06/22 20:08:10 Done.
413 416
414 ~HandleScopeImplementer() { 417 ~HandleScopeImplementer() {
415 DeleteArray(spare_); 418 DeleteArray(spare_);
416 } 419 }
417 420
418 // Threading support for handle data. 421 // Threading support for handle data.
419 static int ArchiveSpacePerThread(); 422 static int ArchiveSpacePerThread();
420 char* RestoreThread(char* from); 423 char* RestoreThread(char* from);
421 char* ArchiveThread(char* to); 424 char* ArchiveThread(char* to);
422 void FreeThreadResources(); 425 void FreeThreadResources();
423 426
424 // Garbage collection support. 427 // Garbage collection support.
425 void Iterate(v8::internal::ObjectVisitor* v); 428 void Iterate(v8::internal::ObjectVisitor* v);
426 static char* Iterate(v8::internal::ObjectVisitor* v, char* data); 429 static char* Iterate(v8::internal::ObjectVisitor* v, char* data);
427 430
431 struct HiddenExtensions {
432 List<Object**> blocks;
433 Object** last_block_end;
434 HiddenExtensions* previous;
435 HiddenExtensions* next;
436 };
428 437
429 inline internal::Object** GetSpareOrNewBlock(); 438 inline internal::Object** GetSpareOrNewBlock();
430 inline void DeleteExtensions(internal::Object** prev_limit); 439 inline void DeleteExtensions(internal::Object** prev_limit);
431 440
441 // HideExtensions must be called _before_ the next field in
442 // HandleScopeData is reverted.
443 HiddenExtensions* HideExtensions(internal::Object** prev_limit);
444 void DeleteHiddenExtensions(HiddenExtensions* extension);
445
432 inline void IncrementCallDepth() {call_depth_++;} 446 inline void IncrementCallDepth() {call_depth_++;}
433 inline void DecrementCallDepth() {call_depth_--;} 447 inline void DecrementCallDepth() {call_depth_--;}
434 inline bool CallDepthIsZero() { return call_depth_ == 0; } 448 inline bool CallDepthIsZero() { return call_depth_ == 0; }
435 449
436 inline void EnterContext(Handle<Object> context); 450 inline void EnterContext(Handle<Object> context);
437 inline bool LeaveLastContext(); 451 inline bool LeaveLastContext();
438 452
439 // Returns the last entered context or an empty handle if no 453 // Returns the last entered context or an empty handle if no
440 // contexts have been entered. 454 // contexts have been entered.
441 inline Handle<Object> LastEnteredContext(); 455 inline Handle<Object> LastEnteredContext();
442 456
443 inline void SaveContext(Context* context); 457 inline void SaveContext(Context* context);
444 inline Context* RestoreContext(); 458 inline Context* RestoreContext();
445 inline bool HasSavedContexts(); 459 inline bool HasSavedContexts();
446 460
447 inline List<internal::Object**>* blocks() { return &blocks_; } 461 inline List<internal::Object**>* blocks() { return &blocks_; }
448 462
463 void set_last_block_before_compilation() {
464 // We only track one such special block.
465 ASSERT(!last_block_before_compilation_);
466 last_block_before_compilation_ = blocks_.last();
467 last_valid_handle_before_compilation_ = isolate_->handle_scope_data()->next;
468 }
469
470 void unset_last_block_before_compilation() {
471 ASSERT(last_block_before_compilation_);
472 last_block_before_compilation_ = NULL;
473 last_valid_handle_before_compilation_ = NULL;
474 }
475
449 private: 476 private:
450 void ResetAfterArchive() { 477 void ResetAfterArchive() {
451 blocks_.Initialize(0); 478 blocks_.Initialize(0);
452 entered_contexts_.Initialize(0); 479 entered_contexts_.Initialize(0);
453 saved_contexts_.Initialize(0); 480 saved_contexts_.Initialize(0);
454 spare_ = NULL; 481 spare_ = NULL;
455 call_depth_ = 0; 482 call_depth_ = 0;
456 } 483 }
457 484
458 void Free() { 485 void Free() {
(...skipping 13 matching lines...) Expand all
472 Isolate* isolate_; 499 Isolate* isolate_;
473 List<internal::Object**> blocks_; 500 List<internal::Object**> blocks_;
474 // Used as a stack to keep track of entered contexts. 501 // Used as a stack to keep track of entered contexts.
475 List<Handle<Object> > entered_contexts_; 502 List<Handle<Object> > entered_contexts_;
476 // Used as a stack to keep track of saved contexts. 503 // Used as a stack to keep track of saved contexts.
477 List<Context*> saved_contexts_; 504 List<Context*> saved_contexts_;
478 Object** spare_; 505 Object** spare_;
479 int call_depth_; 506 int call_depth_;
480 // This is only used for threading support. 507 // This is only used for threading support.
481 v8::ImplementationUtilities::HandleScopeData handle_scope_data_; 508 v8::ImplementationUtilities::HandleScopeData handle_scope_data_;
509 Object** last_block_before_compilation_;
510 Object** last_valid_handle_before_compilation_;
511 HiddenExtensions* hidden_extensions_head_;
482 512
513 template<bool HasCompilationBlock>
483 void IterateThis(ObjectVisitor* v); 514 void IterateThis(ObjectVisitor* v);
484 char* RestoreThreadHelper(char* from); 515 char* RestoreThreadHelper(char* from);
485 char* ArchiveThreadHelper(char* to); 516 char* ArchiveThreadHelper(char* to);
486 517
487 DISALLOW_COPY_AND_ASSIGN(HandleScopeImplementer); 518 DISALLOW_COPY_AND_ASSIGN(HandleScopeImplementer);
488 }; 519 };
489 520
490 521
491 const int kHandleBlockSize = v8::internal::KB - 2; // fit in one page 522 const int kHandleBlockSize = v8::internal::KB - 2; // fit in one page
492 523
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 stress_type_ = stress_type; 597 stress_type_ = stress_type;
567 } 598 }
568 599
569 private: 600 private:
570 static v8::Testing::StressType stress_type_; 601 static v8::Testing::StressType stress_type_;
571 }; 602 };
572 603
573 } } // namespace v8::internal 604 } } // namespace v8::internal
574 605
575 #endif // V8_API_H_ 606 #endif // V8_API_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.cc » ('j') | src/api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698