Reviewers: danno, Michael Starzinger,
https://codereview.chromium.org/21803002/diff/1/src/d8.cc
File src/d8.cc (right):
https://codereview.chromium.org/21803002/diff/1/src/d8.cc#newcode1639
src/d8.cc:1639: virtual void Free(void* data) { UNREACHABLE(); }
The second overload is a workaround for gcc warning ‘virtual void
v8::ArrayBuffer::Allocator::Free(void*)’ was hidden
by ‘virtual void v8::ShellArrayBufferAllocator::Free(void*, size_t)’
[-Werror=overloaded-virtual].
It _looks like_ this is not an error for Blink/chromium (as in, I was
able to build blink and chromium agains this patch on Linux).
Bug https://code.google.com/p/v8/issues/detail?id=2823 tracks cleaning
up the interface
https://codereview.chromium.org/21803002/diff/1/test/cctest/cctest.cc
File test/cctest/cctest.cc (right):
https://codereview.chromium.org/21803002/diff/1/test/cctest/cctest.cc#newcode104
test/cctest/cctest.cc:104: virtual void Free(void* data) {
UNREACHABLE(); }
Workaround for gcc warning, see above
Description:
Add size_t length argument to v8::ArrayBuffer::Allocator::Free.
The previous implementation of Free is a deprecated overload now.
[email protected],[email protected]
Please review this at https://codereview.chromium.org/21803002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M include/v8.h
M src/api.cc
M src/d8.cc
M src/runtime.cc
M test/cctest/cctest.cc
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index
11fccdf023999ff3c3a8acf425c669be29cae54c..311ad434de8516dff174558f15dfe8ae45ad8179
100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -2425,10 +2425,20 @@ class V8EXPORT ArrayBuffer : public Object {
}
/**
- * Free the memory pointed to |data|. That memory is guaranteed to be
- * previously allocated by |Allocate|.
+ * Free the memory block of size |length|, pointed to by |data|.
+ * That memory is guaranteed to be previously allocated by |Allocate|.
*/
- virtual void Free(void* data) = 0;
+ virtual void Free(void* data, size_t length) {
+ // Override with call to |Free(void*)| for compatibility
+ // with legacy version.
+ Free(data);
+ }
+
+ /**
+ * Deprecated. Never called directly by V8.
+ * For compatibility with legacy version of this interface.
+ */
+ virtual void Free(void* data);
};
/**
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index
1ae81b13252e3a1bdf50cb53b66433dd49b053f3..d442126ebbb3c23babfa8cec218edf2fd630480c
100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -3071,6 +3071,12 @@ void v8::ArrayBuffer::CheckCast(Value* that) {
}
+void v8::ArrayBuffer::Allocator::Free(void* data) {
+ API_Fatal("v8::ArrayBuffer::Allocator::Free",
+ "Override Allocator::Free(void*, size_t)");
+}
+
+
void v8::ArrayBufferView::CheckCast(Value* that) {
i::Handle<i::Object> obj = Utils::OpenHandle(that);
ApiCheck(obj->IsJSArrayBufferView(),
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index
e66a2ece600bb0ab54da79510cb4a7db96f75d89..016ce2d3720de3336258ab09b391c5d0bcdb400e
100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -1635,7 +1635,8 @@ class ShellArrayBufferAllocator : public
v8::ArrayBuffer::Allocator {
virtual void* AllocateUninitialized(size_t length) {
return malloc(length);
}
- virtual void Free(void* data) { free(data); }
+ virtual void Free(void* data, size_t) { free(data); }
+ virtual void Free(void* data) { UNREACHABLE(); }
};
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index
df31e70d5c0fcfdefe87e0226717818e8d9ba756..97751470426cc62109970a2f17477e364c9e5ba4
100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -689,7 +689,9 @@ void Runtime::FreeArrayBuffer(Isolate* isolate,
isolate->heap()->AdjustAmountOfExternalAllocatedMemory(
-static_cast<intptr_t>(allocated_length));
CHECK(V8::ArrayBufferAllocator() != NULL);
- V8::ArrayBufferAllocator()->Free(phantom_array_buffer->backing_store());
+ V8::ArrayBufferAllocator()->Free(
+ phantom_array_buffer->backing_store(),
+ allocated_length);
}
Index: test/cctest/cctest.cc
diff --git a/test/cctest/cctest.cc b/test/cctest/cctest.cc
index
94dcce1305223f0f25f6e5456d0959b9f71e04a3..d0139c92d8254965dc593739822eb96427e1fc0f
100644
--- a/test/cctest/cctest.cc
+++ b/test/cctest/cctest.cc
@@ -99,9 +99,9 @@ v8::Isolate* CcTest::default_isolate_;
class CcTestArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
- public:
virtual void* Allocate(size_t length) { return malloc(length); }
- virtual void Free(void* data) { free(data); }
+ virtual void Free(void* data, size_t length) { free(data); }
+ virtual void Free(void* data) { UNREACHABLE(); }
};
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.