| 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 2447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2458 "v8::Object::SetInternalField()", | 2458 "v8::Object::SetInternalField()", |
| 2459 "Writing internal field out of bounds")) { | 2459 "Writing internal field out of bounds")) { |
| 2460 return; | 2460 return; |
| 2461 } | 2461 } |
| 2462 ENTER_V8; | 2462 ENTER_V8; |
| 2463 i::Handle<i::Object> val = Utils::OpenHandle(*value); | 2463 i::Handle<i::Object> val = Utils::OpenHandle(*value); |
| 2464 obj->SetInternalField(index, *val); | 2464 obj->SetInternalField(index, *val); |
| 2465 } | 2465 } |
| 2466 | 2466 |
| 2467 | 2467 |
| 2468 void* v8::Object::GetPointerFromInternalField(int index) { |
| 2469 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
| 2470 i::Object* pointer = obj->GetInternalField(index); |
| 2471 if (pointer->IsSmi()) { |
| 2472 // Fast case, aligned native pointer. |
| 2473 return pointer; |
| 2474 } |
| 2475 |
| 2476 // Read from uninitialized field. |
| 2477 if (!pointer->IsProxy()) { |
| 2478 // Play safe even if it's something unexpected. |
| 2479 ASSERT(pointer->IsUndefined()); |
| 2480 return NULL; |
| 2481 } |
| 2482 |
| 2483 // Unaligned native pointer |
| 2484 return reinterpret_cast<void*>(i::Proxy::cast(pointer)->proxy()); |
| 2485 } |
| 2486 |
| 2487 |
| 2488 void v8::Object::SetPointerInInternalField(int index, void* value) { |
| 2489 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
| 2490 i::Object* as_object = reinterpret_cast<i::Object*>(value); |
| 2491 if (as_object->IsSmi()) { |
| 2492 // Aligned pointer, store as is. |
| 2493 obj->SetInternalField(index, as_object); |
| 2494 } else { |
| 2495 // Currently internal fields are used by DOM wrappers which |
| 2496 // only get GCed by the mark-sweep collector, |
| 2497 // so let's put proxy into old space. |
| 2498 i::Proxy* proxy = *i::Factory::NewProxy(reinterpret_cast<i::Address>(value), |
| 2499 i::TENURED); |
| 2500 obj->SetInternalField(index, proxy); |
| 2501 } |
| 2502 } |
| 2503 |
| 2504 |
| 2468 // --- E n v i r o n m e n t --- | 2505 // --- E n v i r o n m e n t --- |
| 2469 | 2506 |
| 2470 bool v8::V8::Initialize() { | 2507 bool v8::V8::Initialize() { |
| 2471 if (i::V8::IsRunning()) return true; | 2508 if (i::V8::IsRunning()) return true; |
| 2472 ENTER_V8; | 2509 ENTER_V8; |
| 2473 HandleScope scope; | 2510 HandleScope scope; |
| 2474 if (i::Snapshot::Initialize()) { | 2511 if (i::Snapshot::Initialize()) { |
| 2475 return true; | 2512 return true; |
| 2476 } else { | 2513 } else { |
| 2477 return i::V8::Initialize(NULL); | 2514 return i::V8::Initialize(NULL); |
| (...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3526 reinterpret_cast<HandleScopeImplementer*>(storage); | 3563 reinterpret_cast<HandleScopeImplementer*>(storage); |
| 3527 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); | 3564 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); |
| 3528 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = | 3565 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = |
| 3529 &thread_local->handle_scope_data_; | 3566 &thread_local->handle_scope_data_; |
| 3530 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); | 3567 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); |
| 3531 | 3568 |
| 3532 return storage + ArchiveSpacePerThread(); | 3569 return storage + ArchiveSpacePerThread(); |
| 3533 } | 3570 } |
| 3534 | 3571 |
| 3535 } } // namespace v8::internal | 3572 } } // namespace v8::internal |
| OLD | NEW |