| 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 2662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2673 static const int kAlignedPointerShift = 2; | 2673 static const int kAlignedPointerShift = 2; |
| 2674 | 2674 |
| 2675 | 2675 |
| 2676 Local<Value> v8::External::Wrap(void* data) { | 2676 Local<Value> v8::External::Wrap(void* data) { |
| 2677 STATIC_ASSERT(sizeof(data) == sizeof(i::Address)); | 2677 STATIC_ASSERT(sizeof(data) == sizeof(i::Address)); |
| 2678 LOG_API("External::Wrap"); | 2678 LOG_API("External::Wrap"); |
| 2679 EnsureInitialized("v8::External::Wrap()"); | 2679 EnsureInitialized("v8::External::Wrap()"); |
| 2680 ENTER_V8; | 2680 ENTER_V8; |
| 2681 if ((reinterpret_cast<intptr_t>(data) & kAlignedPointerMask) == 0) { | 2681 if ((reinterpret_cast<intptr_t>(data) & kAlignedPointerMask) == 0) { |
| 2682 uintptr_t data_ptr = reinterpret_cast<uintptr_t>(data); | 2682 uintptr_t data_ptr = reinterpret_cast<uintptr_t>(data); |
| 2683 int data_value = static_cast<int>(data_ptr >> kAlignedPointerShift); | 2683 intptr_t data_value = |
| 2684 static_cast<intptr_t>(data_ptr >> kAlignedPointerShift); |
| 2684 STATIC_ASSERT(sizeof(data_ptr) == sizeof(data_value)); | 2685 STATIC_ASSERT(sizeof(data_ptr) == sizeof(data_value)); |
| 2685 i::Handle<i::Object> obj(i::Smi::FromInt(data_value)); | 2686 if (i::Smi::IsPtrValid(data_value)) { |
| 2686 return Utils::ToLocal(obj); | 2687 i::Handle<i::Object> obj(i::Smi::FromIntptr(data_value)); |
| 2688 return Utils::ToLocal(obj); |
| 2689 } |
| 2687 } | 2690 } |
| 2688 return ExternalNewImpl(data); | 2691 return ExternalNewImpl(data); |
| 2689 } | 2692 } |
| 2690 | 2693 |
| 2691 | 2694 |
| 2692 void* v8::External::Unwrap(v8::Handle<v8::Value> value) { | 2695 void* v8::External::Unwrap(v8::Handle<v8::Value> value) { |
| 2693 if (IsDeadCheck("v8::External::Unwrap()")) return 0; | 2696 if (IsDeadCheck("v8::External::Unwrap()")) return 0; |
| 2694 i::Handle<i::Object> obj = Utils::OpenHandle(*value); | 2697 i::Handle<i::Object> obj = Utils::OpenHandle(*value); |
| 2695 if (obj->IsSmi()) { | 2698 if (obj->IsSmi()) { |
| 2696 // The external value was an aligned pointer. | 2699 // The external value was an aligned pointer. |
| 2697 uintptr_t result = i::Smi::cast(*obj)->value() << kAlignedPointerShift; | 2700 uintptr_t result = static_cast<uintptr_t>( |
| 2701 i::Smi::cast(*obj)->value()) << kAlignedPointerShift; |
| 2698 return reinterpret_cast<void*>(result); | 2702 return reinterpret_cast<void*>(result); |
| 2699 } | 2703 } |
| 2700 return ExternalValueImpl(obj); | 2704 return ExternalValueImpl(obj); |
| 2701 } | 2705 } |
| 2702 | 2706 |
| 2703 | 2707 |
| 2704 Local<External> v8::External::New(void* data) { | 2708 Local<External> v8::External::New(void* data) { |
| 2705 STATIC_ASSERT(sizeof(data) == sizeof(i::Address)); | 2709 STATIC_ASSERT(sizeof(data) == sizeof(i::Address)); |
| 2706 LOG_API("External::New"); | 2710 LOG_API("External::New"); |
| 2707 EnsureInitialized("v8::External::New()"); | 2711 EnsureInitialized("v8::External::New()"); |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3458 reinterpret_cast<HandleScopeImplementer*>(storage); | 3462 reinterpret_cast<HandleScopeImplementer*>(storage); |
| 3459 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); | 3463 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); |
| 3460 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = | 3464 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = |
| 3461 &thread_local->handle_scope_data_; | 3465 &thread_local->handle_scope_data_; |
| 3462 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); | 3466 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); |
| 3463 | 3467 |
| 3464 return storage + ArchiveSpacePerThread(); | 3468 return storage + ArchiveSpacePerThread(); |
| 3465 } | 3469 } |
| 3466 | 3470 |
| 3467 } } // namespace v8::internal | 3471 } } // namespace v8::internal |
| OLD | NEW |