| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 static char* RestoreThread(char* from); | 346 static char* RestoreThread(char* from); |
| 347 static char* ArchiveThread(char* to); | 347 static char* ArchiveThread(char* to); |
| 348 static void FreeThreadResources(); | 348 static void FreeThreadResources(); |
| 349 | 349 |
| 350 // Garbage collection support. | 350 // Garbage collection support. |
| 351 static void Iterate(v8::internal::ObjectVisitor* v); | 351 static void Iterate(v8::internal::ObjectVisitor* v); |
| 352 static char* Iterate(v8::internal::ObjectVisitor* v, char* data); | 352 static char* Iterate(v8::internal::ObjectVisitor* v, char* data); |
| 353 | 353 |
| 354 | 354 |
| 355 inline internal::Object** GetSpareOrNewBlock(); | 355 inline internal::Object** GetSpareOrNewBlock(); |
| 356 inline void DeleteExtensions(int extensions); | 356 inline void DeleteExtensions(internal::Object** prev_limit); |
| 357 | 357 |
| 358 inline void IncrementCallDepth() {call_depth_++;} | 358 inline void IncrementCallDepth() {call_depth_++;} |
| 359 inline void DecrementCallDepth() {call_depth_--;} | 359 inline void DecrementCallDepth() {call_depth_--;} |
| 360 inline bool CallDepthIsZero() { return call_depth_ == 0; } | 360 inline bool CallDepthIsZero() { return call_depth_ == 0; } |
| 361 | 361 |
| 362 inline void EnterContext(Handle<Object> context); | 362 inline void EnterContext(Handle<Object> context); |
| 363 inline bool LeaveLastContext(); | 363 inline bool LeaveLastContext(); |
| 364 | 364 |
| 365 // Returns the last entered context or an empty handle if no | 365 // Returns the last entered context or an empty handle if no |
| 366 // contexts have been entered. | 366 // contexts have been entered. |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 // If there's a spare block, use it for growing the current scope. | 458 // If there's a spare block, use it for growing the current scope. |
| 459 internal::Object** HandleScopeImplementer::GetSpareOrNewBlock() { | 459 internal::Object** HandleScopeImplementer::GetSpareOrNewBlock() { |
| 460 internal::Object** block = (spare_ != NULL) ? | 460 internal::Object** block = (spare_ != NULL) ? |
| 461 spare_ : | 461 spare_ : |
| 462 NewArray<internal::Object*>(kHandleBlockSize); | 462 NewArray<internal::Object*>(kHandleBlockSize); |
| 463 spare_ = NULL; | 463 spare_ = NULL; |
| 464 return block; | 464 return block; |
| 465 } | 465 } |
| 466 | 466 |
| 467 | 467 |
| 468 void HandleScopeImplementer::DeleteExtensions(int extensions) { | 468 void HandleScopeImplementer::DeleteExtensions(internal::Object** prev_limit) { |
| 469 if (spare_ != NULL) { | 469 while (!blocks_.is_empty()) { |
| 470 DeleteArray(spare_); | 470 internal::Object** block_start = blocks_.last(); |
| 471 spare_ = NULL; | 471 internal::Object** block_limit = block_start + kHandleBlockSize; |
| 472 #ifdef DEBUG |
| 473 // NoHandleAllocation may make the prev_limit to point inside the block. |
| 474 if (block_start <= prev_limit && prev_limit <= block_limit) break; |
| 475 #else |
| 476 if (prev_limit == block_limit) break; |
| 477 #endif |
| 478 |
| 479 blocks_.RemoveLast(); |
| 480 #ifdef DEBUG |
| 481 v8::ImplementationUtilities::ZapHandleRange(block_start, block_limit); |
| 482 #endif |
| 483 if (spare_ != NULL) { |
| 484 DeleteArray(spare_); |
| 485 } |
| 486 spare_ = block_start; |
| 472 } | 487 } |
| 473 for (int i = extensions; i > 1; --i) { | 488 ASSERT((blocks_.is_empty() && prev_limit == NULL) || |
| 474 internal::Object** block = blocks_.RemoveLast(); | 489 (!blocks_.is_empty() && prev_limit != NULL)); |
| 475 #ifdef DEBUG | |
| 476 v8::ImplementationUtilities::ZapHandleRange(block, | |
| 477 &block[kHandleBlockSize]); | |
| 478 #endif | |
| 479 DeleteArray(block); | |
| 480 } | |
| 481 spare_ = blocks_.RemoveLast(); | |
| 482 #ifdef DEBUG | |
| 483 v8::ImplementationUtilities::ZapHandleRange( | |
| 484 spare_, | |
| 485 &spare_[kHandleBlockSize]); | |
| 486 #endif | |
| 487 } | 490 } |
| 488 | 491 |
| 489 } } // namespace v8::internal | 492 } } // namespace v8::internal |
| 490 | 493 |
| 491 #endif // V8_API_H_ | 494 #endif // V8_API_H_ |
| OLD | NEW |