mirror of
https://github.com/denoland/rusty_v8.git
synced 2025-03-09 13:38:51 -04:00
Refactor 'v8__internal__GetIsolateFromHeapObject' (#415)
It turns out that using `v8::internal::MaybeObject` was, although harmless, not appropriate here, because this function does not deal deal with (potentially) weak handles.
This commit is contained in:
parent
82d0287028
commit
2b11a57d47
1 changed files with 11 additions and 13 deletions
|
@ -10,7 +10,8 @@
|
||||||
#include "v8/include/v8.h"
|
#include "v8/include/v8.h"
|
||||||
#include "v8/src/execution/isolate-utils-inl.h"
|
#include "v8/src/execution/isolate-utils-inl.h"
|
||||||
#include "v8/src/execution/isolate-utils.h"
|
#include "v8/src/execution/isolate-utils.h"
|
||||||
#include "v8/src/objects/maybe-object.h"
|
#include "v8/src/objects/objects-inl.h"
|
||||||
|
#include "v8/src/objects/objects.h"
|
||||||
|
|
||||||
using namespace support;
|
using namespace support;
|
||||||
|
|
||||||
|
@ -1720,18 +1721,15 @@ void v8__HeapProfiler__TakeHeapSnapshot(v8::Isolate* isolate,
|
||||||
'v8_enable_shared_ro_heap' feature enabled.
|
'v8_enable_shared_ro_heap' feature enabled.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
v8::Isolate* v8__internal__GetIsolateFromHeapObject(const v8::Data& location) {
|
v8::Isolate* v8__internal__GetIsolateFromHeapObject(const v8::Data& data) {
|
||||||
auto address = *reinterpret_cast<const v8::internal::Address*>(&location);
|
namespace i = v8::internal;
|
||||||
auto maybe_object = v8::internal::MaybeObject(address);
|
i::Object object(reinterpret_cast<const i::Address&>(data));
|
||||||
if (maybe_object.IsSmi() || maybe_object.IsCleared()) {
|
i::Isolate* isolate;
|
||||||
return nullptr;
|
return object.IsHeapObject() &&
|
||||||
}
|
i::GetIsolateFromHeapObject(object.GetHeapObject(), &isolate)
|
||||||
auto heap_object = maybe_object.GetHeapObject();
|
? reinterpret_cast<v8::Isolate*>(isolate)
|
||||||
v8::internal::Isolate* isolate;
|
: nullptr;
|
||||||
if (!v8::internal::GetIsolateFromHeapObject(heap_object, &isolate)) {
|
}
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
return reinterpret_cast<v8::Isolate*>(isolate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
Loading…
Add table
Reference in a new issue