OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 return result.location(); | 560 return result.location(); |
561 } | 561 } |
562 | 562 |
563 | 563 |
564 void V8::MakeWeak(i::Object** object, void* parameter, | 564 void V8::MakeWeak(i::Object** object, void* parameter, |
565 WeakCallback weak_callback) { | 565 WeakCallback weak_callback) { |
566 i::GlobalHandles::MakeWeak(object, parameter, weak_callback); | 566 i::GlobalHandles::MakeWeak(object, parameter, weak_callback); |
567 } | 567 } |
568 | 568 |
569 | 569 |
570 void V8::MakePhantom(i::Object** object, void* parameter, | 570 void V8::MakeWeak(i::Object** object, void* parameter, |
571 int internal_field_index1, int internal_field_index2, | 571 int internal_field_index1, int internal_field_index2, |
572 PhantomCallbackData<void>::Callback weak_callback) { | 572 WeakCallbackInfo<void>::Callback weak_callback) { |
| 573 WeakCallbackType type = WeakCallbackType::kParameter; |
573 if (internal_field_index1 == 0) { | 574 if (internal_field_index1 == 0) { |
574 if (internal_field_index2 == 1) { | 575 if (internal_field_index2 == 1) { |
575 i::GlobalHandles::MakePhantom(object, parameter, 2, weak_callback); | 576 type = WeakCallbackType::kInternalFields; |
576 } else { | 577 } else { |
577 DCHECK_EQ(internal_field_index2, kNoInternalFieldIndex); | 578 DCHECK_EQ(internal_field_index2, -1); |
578 i::GlobalHandles::MakePhantom(object, parameter, 1, weak_callback); | 579 type = WeakCallbackType::kInternalFields; |
579 } | 580 } |
580 } else { | 581 } else { |
581 DCHECK_EQ(internal_field_index1, kNoInternalFieldIndex); | 582 DCHECK_EQ(internal_field_index1, -1); |
582 DCHECK_EQ(internal_field_index2, kNoInternalFieldIndex); | 583 DCHECK_EQ(internal_field_index2, -1); |
583 i::GlobalHandles::MakePhantom(object, parameter, 0, weak_callback); | |
584 } | 584 } |
| 585 i::GlobalHandles::MakeWeak(object, parameter, weak_callback, type); |
585 } | 586 } |
586 | 587 |
587 | 588 |
| 589 void V8::MakeWeak(i::Object** object, void* parameter, |
| 590 WeakCallbackInfo<void>::Callback weak_callback, |
| 591 WeakCallbackType type) { |
| 592 i::GlobalHandles::MakeWeak(object, parameter, weak_callback, type); |
| 593 } |
| 594 |
| 595 |
588 void* V8::ClearWeak(i::Object** obj) { | 596 void* V8::ClearWeak(i::Object** obj) { |
589 return i::GlobalHandles::ClearWeakness(obj); | 597 return i::GlobalHandles::ClearWeakness(obj); |
590 } | 598 } |
591 | 599 |
592 | 600 |
593 void V8::DisposeGlobal(i::Object** obj) { | 601 void V8::DisposeGlobal(i::Object** obj) { |
594 i::GlobalHandles::Destroy(obj); | 602 i::GlobalHandles::Destroy(obj); |
595 } | 603 } |
596 | 604 |
597 | 605 |
(...skipping 7399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7997 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 8005 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7998 Address callback_address = | 8006 Address callback_address = |
7999 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8007 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8000 VMState<EXTERNAL> state(isolate); | 8008 VMState<EXTERNAL> state(isolate); |
8001 ExternalCallbackScope call_scope(isolate, callback_address); | 8009 ExternalCallbackScope call_scope(isolate, callback_address); |
8002 callback(info); | 8010 callback(info); |
8003 } | 8011 } |
8004 | 8012 |
8005 | 8013 |
8006 } } // namespace v8::internal | 8014 } } // namespace v8::internal |
OLD | NEW |