| 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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 inline void DecrementCallDepth() {call_depth--;} | 345 inline void DecrementCallDepth() {call_depth--;} |
| 346 inline bool CallDepthIsZero() { return call_depth == 0; } | 346 inline bool CallDepthIsZero() { return call_depth == 0; } |
| 347 | 347 |
| 348 inline void EnterContext(Handle<Object> context); | 348 inline void EnterContext(Handle<Object> context); |
| 349 inline bool LeaveLastContext(); | 349 inline bool LeaveLastContext(); |
| 350 | 350 |
| 351 // Returns the last entered context or an empty handle if no | 351 // Returns the last entered context or an empty handle if no |
| 352 // contexts have been entered. | 352 // contexts have been entered. |
| 353 inline Handle<Object> LastEnteredContext(); | 353 inline Handle<Object> LastEnteredContext(); |
| 354 | 354 |
| 355 inline void SaveContext(Handle<Object> context); | 355 inline void SaveContext(Context* context); |
| 356 inline Handle<Object> RestoreContext(); | 356 inline Context* RestoreContext(); |
| 357 inline bool HasSavedContexts(); | 357 inline bool HasSavedContexts(); |
| 358 | 358 |
| 359 inline List<internal::Object**>* Blocks() { return &blocks; } | 359 inline List<internal::Object**>* Blocks() { return &blocks; } |
| 360 | 360 |
| 361 inline bool IgnoreOutOfMemory() { return ignore_out_of_memory; } | 361 inline bool IgnoreOutOfMemory() { return ignore_out_of_memory; } |
| 362 inline void SetIgnoreOutOfMemory(bool value) { ignore_out_of_memory = value; } | 362 inline void SetIgnoreOutOfMemory(bool value) { ignore_out_of_memory = value; } |
| 363 | 363 |
| 364 private: | 364 private: |
| 365 List<internal::Object**> blocks; | 365 List<internal::Object**> blocks; |
| 366 Object** spare; | 366 Object** spare; |
| 367 int call_depth; | 367 int call_depth; |
| 368 // Used as a stack to keep track of entered contexts. | 368 // Used as a stack to keep track of entered contexts. |
| 369 List<Handle<Object> > entered_contexts_; | 369 List<Handle<Object> > entered_contexts_; |
| 370 // Used as a stack to keep track of saved contexts. | 370 // Used as a stack to keep track of saved contexts. |
| 371 List<Handle<Object> > saved_contexts_; | 371 List<Context*> saved_contexts_; |
| 372 bool ignore_out_of_memory; | 372 bool ignore_out_of_memory; |
| 373 // This is only used for threading support. | 373 // This is only used for threading support. |
| 374 v8::ImplementationUtilities::HandleScopeData handle_scope_data_; | 374 v8::ImplementationUtilities::HandleScopeData handle_scope_data_; |
| 375 | 375 |
| 376 static void Iterate(ObjectVisitor* v, | 376 void IterateThis(ObjectVisitor* v); |
| 377 List<internal::Object**>* blocks, | |
| 378 v8::ImplementationUtilities::HandleScopeData* handle_data); | |
| 379 char* RestoreThreadHelper(char* from); | 377 char* RestoreThreadHelper(char* from); |
| 380 char* ArchiveThreadHelper(char* to); | 378 char* ArchiveThreadHelper(char* to); |
| 381 | 379 |
| 382 DISALLOW_COPY_AND_ASSIGN(HandleScopeImplementer); | 380 DISALLOW_COPY_AND_ASSIGN(HandleScopeImplementer); |
| 383 }; | 381 }; |
| 384 | 382 |
| 385 | 383 |
| 386 static const int kHandleBlockSize = v8::internal::KB - 2; // fit in one page | 384 static const int kHandleBlockSize = v8::internal::KB - 2; // fit in one page |
| 387 | 385 |
| 388 | 386 |
| 389 void HandleScopeImplementer::SaveContext(Handle<Object> context) { | 387 void HandleScopeImplementer::SaveContext(Context* context) { |
| 390 saved_contexts_.Add(context); | 388 saved_contexts_.Add(context); |
| 391 } | 389 } |
| 392 | 390 |
| 393 | 391 |
| 394 Handle<Object> HandleScopeImplementer::RestoreContext() { | 392 Context* HandleScopeImplementer::RestoreContext() { |
| 395 return saved_contexts_.RemoveLast(); | 393 return saved_contexts_.RemoveLast(); |
| 396 } | 394 } |
| 397 | 395 |
| 398 | 396 |
| 399 bool HandleScopeImplementer::HasSavedContexts() { | 397 bool HandleScopeImplementer::HasSavedContexts() { |
| 400 return !saved_contexts_.is_empty(); | 398 return !saved_contexts_.is_empty(); |
| 401 } | 399 } |
| 402 | 400 |
| 403 | 401 |
| 404 void HandleScopeImplementer::EnterContext(Handle<Object> context) { | 402 void HandleScopeImplementer::EnterContext(Handle<Object> context) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 #ifdef DEBUG | 444 #ifdef DEBUG |
| 447 v8::ImplementationUtilities::ZapHandleRange( | 445 v8::ImplementationUtilities::ZapHandleRange( |
| 448 spare, | 446 spare, |
| 449 &spare[kHandleBlockSize]); | 447 &spare[kHandleBlockSize]); |
| 450 #endif | 448 #endif |
| 451 } | 449 } |
| 452 | 450 |
| 453 } } // namespace v8::internal | 451 } } // namespace v8::internal |
| 454 | 452 |
| 455 #endif // V8_API_H_ | 453 #endif // V8_API_H_ |
| OLD | NEW |