Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Unified Diff: src/d8.cc

Issue 1089853005: prepare to deprecate non phantom weak callbacks (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index 0d1b93699bc9ef3342df90d84616f1dec7746124..cf448172f7a9f8afd500a240abbe0d9312647034 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -1130,13 +1130,14 @@ static char* ReadChars(Isolate* isolate, const char* name, int* size_out) {
struct DataAndPersistent {
uint8_t* data;
- Persistent<ArrayBuffer> handle;
+ int byte_length;
+ Global<ArrayBuffer> handle;
};
static void ReadBufferWeakCallback(
- const v8::WeakCallbackData<ArrayBuffer, DataAndPersistent>& data) {
- size_t byte_length = data.GetValue()->ByteLength();
+ const v8::WeakCallbackInfo<DataAndPersistent>& data) {
+ int byte_length = data.GetParameter()->byte_length;
data.GetIsolate()->AdjustAmountOfExternalAllocatedMemory(
-static_cast<intptr_t>(byte_length));
@@ -1164,10 +1165,12 @@ void Shell::ReadBuffer(const v8::FunctionCallbackInfo<v8::Value>& args) {
Throw(args.GetIsolate(), "Error reading file");
return;
}
+ data->byte_length = length;
Handle<v8::ArrayBuffer> buffer =
ArrayBuffer::New(isolate, data->data, length);
data->handle.Reset(isolate, buffer);
- data->handle.SetWeak(data, ReadBufferWeakCallback);
+ data->handle.SetWeak(data, ReadBufferWeakCallback,
+ v8::WeakCallbackType::kParameter);
data->handle.MarkIndependent();
isolate->AdjustAmountOfExternalAllocatedMemory(length);
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698