Chromium Code Reviews| Index: src/d8.cc |
| diff --git a/src/d8.cc b/src/d8.cc |
| index 7c5df463d334564347bc6e0fd273982a48f09efd..cc4a40a8f4b2afe6002850f3c55a287898f76562 100644 |
| --- a/src/d8.cc |
| +++ b/src/d8.cc |
| @@ -48,6 +48,8 @@ |
| #include <algorithm> |
| #endif // !V8_SHARED |
| +#include <utility> |
|
Michael Starzinger
2013/12/02 15:34:10
nit: Can we move this up to the other system inclu
Sven Panne
2013/12/02 17:30:53
Nope, the presubmit check insists on this order: C
|
| + |
| #ifdef V8_SHARED |
| #include "../include/v8-testing.h" |
| #endif // V8_SHARED |
| @@ -1097,16 +1099,14 @@ static char* ReadChars(Isolate* isolate, const char* name, int* size_out) { |
| return chars; |
| } |
| -static void ReadBufferWeakCallback(v8::Isolate* isolate, |
| - Persistent<ArrayBuffer>* array_buffer, |
| - uint8_t* data) { |
| - size_t byte_length = |
| - Local<ArrayBuffer>::New(isolate, *array_buffer)->ByteLength(); |
| - isolate->AdjustAmountOfExternalAllocatedMemory( |
| - -static_cast<intptr_t>(byte_length)); |
| - |
| - delete[] data; |
| - array_buffer->Reset(); |
| +static void ReadBufferWeakCallback( |
| + const WeakCallbackData<v8::ArrayBuffer, |
| + std::pair<v8::Persistent<v8::ArrayBuffer>*, |
| + uint8_t*> >& data) { |
| + data.GetIsolate()->AdjustAmountOfExternalAllocatedMemory( |
| + -data.GetValue()->ByteLength()); |
|
Michael Starzinger
2013/12/02 15:34:10
I guess there will be some casting problem between
Sven Panne
2013/12/02 17:30:53
To be honest, I would prefer to see a compiler war
|
| + delete[] data.GetParameter()->second; |
| + data.GetParameter()->first->Reset(); |
| } |
| @@ -1128,7 +1128,9 @@ void Shell::ReadBuffer(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| } |
| Handle<v8::ArrayBuffer> buffer = ArrayBuffer::New(isolate, data, length); |
| v8::Persistent<v8::ArrayBuffer> weak_handle(isolate, buffer); |
| - weak_handle.MakeWeak(data, ReadBufferWeakCallback); |
| + std::pair<v8::Persistent<v8::ArrayBuffer>*, uint8_t*> pair(&weak_handle, |
| + data); |
| + weak_handle.SetWeak(&pair, ReadBufferWeakCallback); |
| weak_handle.MarkIndependent(); |
| isolate->AdjustAmountOfExternalAllocatedMemory(length); |