OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 | 450 |
451 void V8::DisposeGlobal(i::Object** obj) { | 451 void V8::DisposeGlobal(i::Object** obj) { |
452 LOG_API("DisposeGlobal"); | 452 LOG_API("DisposeGlobal"); |
453 if (!i::V8::IsRunning()) return; | 453 if (!i::V8::IsRunning()) return; |
454 i::GlobalHandles::Destroy(obj); | 454 i::GlobalHandles::Destroy(obj); |
455 } | 455 } |
456 | 456 |
457 // --- H a n d l e s --- | 457 // --- H a n d l e s --- |
458 | 458 |
459 | 459 |
460 HandleScope::HandleScope() : is_closed_(false) { | 460 HandleScope::HandleScope() |
| 461 : prev_next_(i::HandleScope::current_.next), |
| 462 prev_limit_(i::HandleScope::current_.limit), |
| 463 is_closed_(false) { |
461 API_ENTRY_CHECK("HandleScope::HandleScope"); | 464 API_ENTRY_CHECK("HandleScope::HandleScope"); |
462 i::HandleScope::Enter(&previous_); | 465 i::HandleScope::current_.level++; |
463 } | 466 } |
464 | 467 |
465 | 468 |
466 HandleScope::~HandleScope() { | 469 HandleScope::~HandleScope() { |
467 if (!is_closed_) { | 470 if (!is_closed_) { |
468 i::HandleScope::Leave(&previous_); | 471 Leave(); |
469 } | 472 } |
470 } | 473 } |
471 | 474 |
472 | 475 |
| 476 void HandleScope::Leave() { |
| 477 i::HandleScope::current_.level--; |
| 478 ASSERT(i::HandleScope::current_.level >= 0); |
| 479 i::HandleScope::current_.next = prev_next_; |
| 480 if (i::HandleScope::current_.limit != prev_limit_) { |
| 481 i::HandleScope::current_.limit = prev_limit_; |
| 482 i::HandleScope::DeleteExtensions(); |
| 483 } |
| 484 |
| 485 #ifdef DEBUG |
| 486 i::HandleScope::ZapRange(prev_next_, prev_limit_); |
| 487 #endif |
| 488 } |
| 489 |
| 490 |
473 int HandleScope::NumberOfHandles() { | 491 int HandleScope::NumberOfHandles() { |
474 return i::HandleScope::NumberOfHandles(); | 492 return i::HandleScope::NumberOfHandles(); |
475 } | 493 } |
476 | 494 |
477 | 495 |
478 i::Object** v8::HandleScope::CreateHandle(i::Object* value) { | 496 i::Object** v8::HandleScope::CreateHandle(i::Object* value) { |
479 return i::HandleScope::CreateHandle(value); | 497 return i::HandleScope::CreateHandle(value); |
480 } | 498 } |
481 | 499 |
482 | 500 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 return 0; | 564 return 0; |
547 } | 565 } |
548 LOG_API("CloseHandleScope"); | 566 LOG_API("CloseHandleScope"); |
549 | 567 |
550 // Read the result before popping the handle block. | 568 // Read the result before popping the handle block. |
551 i::Object* result = NULL; | 569 i::Object* result = NULL; |
552 if (value != NULL) { | 570 if (value != NULL) { |
553 result = *value; | 571 result = *value; |
554 } | 572 } |
555 is_closed_ = true; | 573 is_closed_ = true; |
556 i::HandleScope::Leave(&previous_); | 574 Leave(); |
557 | 575 |
558 if (value == NULL) { | 576 if (value == NULL) { |
559 return NULL; | 577 return NULL; |
560 } | 578 } |
561 | 579 |
562 // Allocate a new handle on the previous handle block. | 580 // Allocate a new handle on the previous handle block. |
563 i::Handle<i::Object> handle(result); | 581 i::Handle<i::Object> handle(result); |
564 return handle.location(); | 582 return handle.location(); |
565 } | 583 } |
566 | 584 |
(...skipping 4402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4969 | 4987 |
4970 | 4988 |
4971 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 4989 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
4972 HandleScopeImplementer* thread_local = | 4990 HandleScopeImplementer* thread_local = |
4973 reinterpret_cast<HandleScopeImplementer*>(storage); | 4991 reinterpret_cast<HandleScopeImplementer*>(storage); |
4974 thread_local->IterateThis(v); | 4992 thread_local->IterateThis(v); |
4975 return storage + ArchiveSpacePerThread(); | 4993 return storage + ArchiveSpacePerThread(); |
4976 } | 4994 } |
4977 | 4995 |
4978 } } // namespace v8::internal | 4996 } } // namespace v8::internal |
OLD | NEW |