OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 return; | 438 return; |
439 } | 439 } |
440 | 440 |
441 // Content of 'last_context' could be NULL. | 441 // Content of 'last_context' could be NULL. |
442 i::Handle<i::Object> last_context = thread_local.RestoreContext(); | 442 i::Handle<i::Object> last_context = thread_local.RestoreContext(); |
443 i::Top::set_context(static_cast<i::Context*>(*last_context)); | 443 i::Top::set_context(static_cast<i::Context*>(*last_context)); |
444 i::GlobalHandles::Destroy(last_context.location()); | 444 i::GlobalHandles::Destroy(last_context.location()); |
445 } | 445 } |
446 | 446 |
447 | 447 |
| 448 void Context::SetData(v8::Handle<Value> data) { |
| 449 if (IsDeadCheck("v8::Context::SetData()")) return; |
| 450 ENTER_V8; |
| 451 { |
| 452 HandleScope scope; |
| 453 i::Handle<i::Context> env = Utils::OpenHandle(this); |
| 454 i::Handle<i::Object> raw_data = Utils::OpenHandle(*data); |
| 455 ASSERT(env->IsGlobalContext()); |
| 456 if (env->IsGlobalContext()) { |
| 457 env->set_data(*raw_data); |
| 458 } |
| 459 } |
| 460 } |
| 461 |
| 462 |
| 463 v8::Local<v8::Value> Context::GetData() { |
| 464 if (IsDeadCheck("v8::Context::GetData()")) return v8::Local<Value>(); |
| 465 ENTER_V8; |
| 466 i::Object* raw_result = NULL; |
| 467 { |
| 468 HandleScope scope; |
| 469 i::Handle<i::Context> env = Utils::OpenHandle(this); |
| 470 ASSERT(env->IsGlobalContext()); |
| 471 if (env->IsGlobalContext()) { |
| 472 raw_result = env->data(); |
| 473 } else { |
| 474 return Local<Value>(); |
| 475 } |
| 476 } |
| 477 i::Handle<i::Object> result(raw_result); |
| 478 return Utils::ToLocal(result); |
| 479 } |
| 480 |
| 481 |
448 void** v8::HandleScope::RawClose(void** value) { | 482 void** v8::HandleScope::RawClose(void** value) { |
449 if (!ApiCheck(!is_closed_, | 483 if (!ApiCheck(!is_closed_, |
450 "v8::HandleScope::Close()", | 484 "v8::HandleScope::Close()", |
451 "Local scope has already been closed")) { | 485 "Local scope has already been closed")) { |
452 return 0; | 486 return 0; |
453 } | 487 } |
454 LOG_API("CloseHandleScope"); | 488 LOG_API("CloseHandleScope"); |
455 | 489 |
456 // Read the result before popping the handle block. | 490 // Read the result before popping the handle block. |
457 i::Object* result = reinterpret_cast<i::Object*>(*value); | 491 i::Object* result = reinterpret_cast<i::Object*>(*value); |
(...skipping 2961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3419 reinterpret_cast<HandleScopeImplementer*>(storage); | 3453 reinterpret_cast<HandleScopeImplementer*>(storage); |
3420 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); | 3454 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); |
3421 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = | 3455 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = |
3422 &thread_local->handle_scope_data_; | 3456 &thread_local->handle_scope_data_; |
3423 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); | 3457 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); |
3424 | 3458 |
3425 return storage + ArchiveSpacePerThread(); | 3459 return storage + ArchiveSpacePerThread(); |
3426 } | 3460 } |
3427 | 3461 |
3428 } } // namespace v8::internal | 3462 } } // namespace v8::internal |
OLD | NEW |