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

Unified Diff: test/cctest/test-api.cc

Issue 15855012: Change ArrayBuffer API and implementation to use embedder-provided allocator. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: CR feedback Created 7 years, 6 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 | « test/cctest/cctest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index a69fe902a4293740a692416e4f4b5c0b57b08f5c..4d0b9eaef3eea6b6142c2aef331bbfe7287d360f 100755
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -2547,6 +2547,19 @@ THREADED_TEST(SymbolProperties) {
}
+class ScopedArrayBufferContents {
+ public:
+ explicit ScopedArrayBufferContents(
+ const v8::ArrayBuffer::Contents& contents)
+ : contents_(contents) {}
+ ~ScopedArrayBufferContents() { free(contents_.Data()); }
+ void* Data() const { return contents_.Data(); }
+ size_t ByteLength() const { return contents_.ByteLength(); }
+ private:
+ const v8::ArrayBuffer::Contents contents_;
+};
+
+
THREADED_TEST(ArrayBuffer_ApiInternalToExternal) {
i::FLAG_harmony_array_buffer = true;
i::FLAG_harmony_typed_arrays = true;
@@ -2560,8 +2573,7 @@ THREADED_TEST(ArrayBuffer_ApiInternalToExternal) {
CHECK(!ab->IsExternal());
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
- v8::ArrayBufferContents ab_contents;
- ab->Externalize(&ab_contents);
+ ScopedArrayBufferContents ab_contents(ab->Externalize());
CHECK(ab->IsExternal());
CHECK_EQ(1024, static_cast<int>(ab_contents.ByteLength()));
@@ -2603,8 +2615,7 @@ THREADED_TEST(ArrayBuffer_JSInternalToExternal) {
Local<v8::ArrayBuffer> ab1 = v8::ArrayBuffer::Cast(*result);
CHECK_EQ(2, static_cast<int>(ab1->ByteLength()));
CHECK(!ab1->IsExternal());
- v8::ArrayBufferContents ab1_contents;
- ab1->Externalize(&ab1_contents);
+ ScopedArrayBufferContents ab1_contents(ab1->Externalize());
CHECK(ab1->IsExternal());
result = CompileRun("ab1.byteLength");
@@ -2711,8 +2722,7 @@ THREADED_TEST(ArrayBuffer_NeuteringApi) {
v8::Handle<v8::Float64Array> f64a =
CreateAndCheck<v8::Float64Array, 8>(buffer, 8, 127);
- v8::ArrayBufferContents contents;
- buffer->Externalize(&contents);
+ ScopedArrayBufferContents contents(buffer->Externalize());
buffer->Neuter();
CHECK_EQ(0, static_cast<int>(buffer->ByteLength()));
CheckIsNeutered(u8a);
@@ -2763,8 +2773,7 @@ THREADED_TEST(ArrayBuffer_NeuteringScript) {
v8::Handle<v8::Float64Array> f64a(
v8::Float64Array::Cast(*CompileRun("f64a")));
- v8::ArrayBufferContents contents;
- ab->Externalize(&contents);
+ ScopedArrayBufferContents contents(ab->Externalize());
ab->Neuter();
CHECK_EQ(0, static_cast<int>(ab->ByteLength()));
CheckIsNeutered(u8a);
« no previous file with comments | « test/cctest/cctest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698