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

Side by Side Diff: src/api.h

Issue 10778036: The deferred handes list belongs to the Isolate and not to the (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review. 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 | « no previous file | src/api.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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 390
391 DISALLOW_COPY_AND_ASSIGN(StringTracker); 391 DISALLOW_COPY_AND_ASSIGN(StringTracker);
392 }; 392 };
393 393
394 394
395 class DeferredHandles { 395 class DeferredHandles {
396 public: 396 public:
397 ~DeferredHandles(); 397 ~DeferredHandles();
398 398
399 private: 399 private:
400 DeferredHandles(DeferredHandles* next, Object** first_block_limit, 400 DeferredHandles(Object** first_block_limit, Isolate* isolate)
401 HandleScopeImplementer* impl) 401 : next_(NULL),
402 : next_(next),
403 previous_(NULL), 402 previous_(NULL),
404 first_block_limit_(first_block_limit), 403 first_block_limit_(first_block_limit),
405 impl_(impl) { 404 isolate_(isolate) {
406 if (next != NULL) next->previous_ = this; 405 isolate->LinkDeferredHandles(this);
407 } 406 }
408 407
409 void Iterate(ObjectVisitor* v); 408 void Iterate(ObjectVisitor* v);
410 409
411 List<Object**> blocks_; 410 List<Object**> blocks_;
412 DeferredHandles* next_; 411 DeferredHandles* next_;
413 DeferredHandles* previous_; 412 DeferredHandles* previous_;
414 Object** first_block_limit_; 413 Object** first_block_limit_;
415 HandleScopeImplementer* impl_; 414 Isolate* isolate_;
416 415
417 friend class HandleScopeImplementer; 416 friend class HandleScopeImplementer;
417 friend class Isolate;
418 }; 418 };
419 419
420 420
421 // This class is here in order to be able to declare it a friend of 421 // This class is here in order to be able to declare it a friend of
422 // HandleScope. Moving these methods to be members of HandleScope would be 422 // HandleScope. Moving these methods to be members of HandleScope would be
423 // neat in some ways, but it would expose internal implementation details in 423 // neat in some ways, but it would expose internal implementation details in
424 // our public header file, which is undesirable. 424 // our public header file, which is undesirable.
425 // 425 //
426 // An isolate has a single instance of this class to hold the current thread's 426 // An isolate has a single instance of this class to hold the current thread's
427 // data. In multithreaded V8 programs this data is copied in and out of storage 427 // data. In multithreaded V8 programs this data is copied in and out of storage
428 // so that the currently executing thread always has its own copy of this 428 // so that the currently executing thread always has its own copy of this
429 // data. 429 // data.
430 class HandleScopeImplementer { 430 class HandleScopeImplementer {
431 public: 431 public:
432 explicit HandleScopeImplementer(Isolate* isolate) 432 explicit HandleScopeImplementer(Isolate* isolate)
433 : isolate_(isolate), 433 : isolate_(isolate),
434 blocks_(0), 434 blocks_(0),
435 entered_contexts_(0), 435 entered_contexts_(0),
436 saved_contexts_(0), 436 saved_contexts_(0),
437 spare_(NULL), 437 spare_(NULL),
438 call_depth_(0), 438 call_depth_(0),
439 last_handle_before_deferred_block_(NULL), 439 last_handle_before_deferred_block_(NULL) { }
440 deferred_handles_head_(NULL) { }
441 440
442 ~HandleScopeImplementer() { 441 ~HandleScopeImplementer() {
443 DeleteArray(spare_); 442 DeleteArray(spare_);
444 } 443 }
445 444
446 // Threading support for handle data. 445 // Threading support for handle data.
447 static int ArchiveSpacePerThread(); 446 static int ArchiveSpacePerThread();
448 char* RestoreThread(char* from); 447 char* RestoreThread(char* from);
449 char* ArchiveThread(char* to); 448 char* ArchiveThread(char* to);
450 void FreeThreadResources(); 449 void FreeThreadResources();
(...skipping 17 matching lines...) Expand all
468 // contexts have been entered. 467 // contexts have been entered.
469 inline Handle<Object> LastEnteredContext(); 468 inline Handle<Object> LastEnteredContext();
470 469
471 inline void SaveContext(Context* context); 470 inline void SaveContext(Context* context);
472 inline Context* RestoreContext(); 471 inline Context* RestoreContext();
473 inline bool HasSavedContexts(); 472 inline bool HasSavedContexts();
474 473
475 inline List<internal::Object**>* blocks() { return &blocks_; } 474 inline List<internal::Object**>* blocks() { return &blocks_; }
476 Isolate* isolate() const { return isolate_; } 475 Isolate* isolate() const { return isolate_; }
477 476
477 void ReturnBlock(Object** block) {
478 ASSERT(block != NULL);
479 if (spare_ != NULL) DeleteArray(spare_);
480 spare_ = block;
481 }
482
478 private: 483 private:
479 void ResetAfterArchive() { 484 void ResetAfterArchive() {
480 blocks_.Initialize(0); 485 blocks_.Initialize(0);
481 entered_contexts_.Initialize(0); 486 entered_contexts_.Initialize(0);
482 saved_contexts_.Initialize(0); 487 saved_contexts_.Initialize(0);
483 spare_ = NULL; 488 spare_ = NULL;
484 deferred_handles_head_ = NULL;
485 last_handle_before_deferred_block_ = NULL; 489 last_handle_before_deferred_block_ = NULL;
486 call_depth_ = 0; 490 call_depth_ = 0;
487 } 491 }
488 492
489 void Free() { 493 void Free() {
490 ASSERT(blocks_.length() == 0); 494 ASSERT(blocks_.length() == 0);
491 ASSERT(entered_contexts_.length() == 0); 495 ASSERT(entered_contexts_.length() == 0);
492 ASSERT(saved_contexts_.length() == 0); 496 ASSERT(saved_contexts_.length() == 0);
493 ASSERT(deferred_handles_head_ == NULL);
494 blocks_.Free(); 497 blocks_.Free();
495 entered_contexts_.Free(); 498 entered_contexts_.Free();
496 saved_contexts_.Free(); 499 saved_contexts_.Free();
497 if (spare_ != NULL) { 500 if (spare_ != NULL) {
498 DeleteArray(spare_); 501 DeleteArray(spare_);
499 spare_ = NULL; 502 spare_ = NULL;
500 } 503 }
501 ASSERT(call_depth_ == 0); 504 ASSERT(call_depth_ == 0);
502 } 505 }
503 506
504 void BeginDeferredScope(); 507 void BeginDeferredScope();
505 DeferredHandles* Detach(Object** prev_limit); 508 DeferredHandles* Detach(Object** prev_limit);
506 void DestroyDeferredHandles(DeferredHandles* handles);
507 509
508 Isolate* isolate_; 510 Isolate* isolate_;
509 List<internal::Object**> blocks_; 511 List<internal::Object**> blocks_;
510 // Used as a stack to keep track of entered contexts. 512 // Used as a stack to keep track of entered contexts.
511 List<Handle<Object> > entered_contexts_; 513 List<Handle<Object> > entered_contexts_;
512 // Used as a stack to keep track of saved contexts. 514 // Used as a stack to keep track of saved contexts.
513 List<Context*> saved_contexts_; 515 List<Context*> saved_contexts_;
514 Object** spare_; 516 Object** spare_;
515 int call_depth_; 517 int call_depth_;
516 Object** last_handle_before_deferred_block_; 518 Object** last_handle_before_deferred_block_;
517 DeferredHandles* deferred_handles_head_;
518 // This is only used for threading support. 519 // This is only used for threading support.
519 v8::ImplementationUtilities::HandleScopeData handle_scope_data_; 520 v8::ImplementationUtilities::HandleScopeData handle_scope_data_;
520 521
521 void IterateThis(ObjectVisitor* v); 522 void IterateThis(ObjectVisitor* v);
522 char* RestoreThreadHelper(char* from); 523 char* RestoreThreadHelper(char* from);
523 char* ArchiveThreadHelper(char* to); 524 char* ArchiveThreadHelper(char* to);
524 525
525 friend class DeferredHandles; 526 friend class DeferredHandles;
526 friend class DeferredHandleScope; 527 friend class DeferredHandleScope;
527 528
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 stress_type_ = stress_type; 608 stress_type_ = stress_type;
608 } 609 }
609 610
610 private: 611 private:
611 static v8::Testing::StressType stress_type_; 612 static v8::Testing::StressType stress_type_;
612 }; 613 };
613 614
614 } } // namespace v8::internal 615 } } // namespace v8::internal
615 616
616 #endif // V8_API_H_ 617 #endif // V8_API_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698