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

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

Issue 2185963002: [api] Add v8::Object::SetAlignedPointerInInternalFields (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: removing inlined helper Created 4 years, 4 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 | « src/api.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 510fc26de4ff21ee5142213afd70908990bb032e..ef1cdb514065c59307ca83a5b4c2b32f9c804763 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -2683,6 +2683,40 @@ THREADED_TEST(InternalFieldsAlignedPointers) {
CHECK_EQ(huge, Object::GetAlignedPointerFromInternalField(persistent, 0));
}
+THREADED_TEST(SetAlignedPointerInInternalFields) {
+ LocalContext env;
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
+
+ Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
+ Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate();
+ instance_templ->SetInternalFieldCount(2);
+ Local<v8::Object> obj = templ->GetFunction(env.local())
+ .ToLocalChecked()
+ ->NewInstance(env.local())
+ .ToLocalChecked();
+ CHECK_EQ(2, obj->InternalFieldCount());
+
+ int* heap_allocated_1 = new int[100];
+ int* heap_allocated_2 = new int[100];
+ int indices[] = {0, 1};
+ void* values[] = {heap_allocated_1, heap_allocated_2};
+
+ obj->SetAlignedPointerInInternalFields(2, indices, values);
+ CcTest::heap()->CollectAllGarbage();
+ CHECK_EQ(heap_allocated_1, obj->GetAlignedPointerFromInternalField(0));
+ CHECK_EQ(heap_allocated_2, obj->GetAlignedPointerFromInternalField(1));
+
+ indices[0] = 1;
+ indices[1] = 0;
+ obj->SetAlignedPointerInInternalFields(2, indices, values);
+ CcTest::heap()->CollectAllGarbage();
+ CHECK_EQ(heap_allocated_2, obj->GetAlignedPointerFromInternalField(0));
+ CHECK_EQ(heap_allocated_1, obj->GetAlignedPointerFromInternalField(1));
+
+ delete[] heap_allocated_1;
+ delete[] heap_allocated_2;
+}
static void CheckAlignedPointerInEmbedderData(LocalContext* env, int index,
void* value) {
@@ -2724,7 +2758,6 @@ THREADED_TEST(EmbedderDataAlignedPointers) {
}
}
-
static void CheckEmbedderData(LocalContext* env, int index,
v8::Local<Value> data) {
(*env)->SetEmbedderData(index, data);
« no previous file with comments | « src/api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698