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

Side by Side Diff: test/cctest/test-declarative-accessors.cc

Issue 157503002: A64: Synchronize with r18444. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-debug.cc ('k') | test/cctest/test-decls.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 }; 88 };
89 89
90 90
91 static v8::Local<v8::ObjectTemplate> CreateConstructor( 91 static v8::Local<v8::ObjectTemplate> CreateConstructor(
92 v8::Handle<v8::Context> context, 92 v8::Handle<v8::Context> context,
93 const char* class_name, 93 const char* class_name,
94 int internal_field, 94 int internal_field,
95 const char* descriptor_name = NULL, 95 const char* descriptor_name = NULL,
96 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor = 96 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor =
97 v8::Handle<v8::DeclaredAccessorDescriptor>()) { 97 v8::Handle<v8::DeclaredAccessorDescriptor>()) {
98 v8::Local<v8::FunctionTemplate> constructor = v8::FunctionTemplate::New(); 98 v8::Local<v8::FunctionTemplate> constructor =
99 v8::FunctionTemplate::New(context->GetIsolate());
99 v8::Local<v8::ObjectTemplate> obj_template = constructor->InstanceTemplate(); 100 v8::Local<v8::ObjectTemplate> obj_template = constructor->InstanceTemplate();
100 // Setup object template. 101 // Setup object template.
101 if (descriptor_name != NULL && !descriptor.IsEmpty()) { 102 if (descriptor_name != NULL && !descriptor.IsEmpty()) {
102 bool added_accessor = 103 bool added_accessor =
103 obj_template->SetDeclaredAccessor(v8_str(descriptor_name), descriptor); 104 obj_template->SetDeclaredAccessor(v8_str(descriptor_name), descriptor);
104 CHECK(added_accessor); 105 CHECK(added_accessor);
105 } 106 }
106 obj_template->SetInternalFieldCount((internal_field+1)*2 + 7); 107 obj_template->SetInternalFieldCount((internal_field+1)*2 + 7);
107 context->Global()->Set(v8_str(class_name), constructor->GetFunction()); 108 context->Global()->Set(v8_str(class_name), constructor->GetFunction());
108 return obj_template; 109 return obj_template;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 v8::HandleScope handle_scope(helper->isolate_); 171 v8::HandleScope handle_scope(helper->isolate_);
171 int index = 17; 172 int index = 17;
172 int internal_field = 6; 173 int internal_field = 6;
173 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor = 174 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor =
174 OOD::NewInternalFieldDereference(helper->isolate_, internal_field) 175 OOD::NewInternalFieldDereference(helper->isolate_, internal_field)
175 ->NewRawShift(helper->isolate_, static_cast<uint16_t>(index*sizeof(T))) 176 ->NewRawShift(helper->isolate_, static_cast<uint16_t>(index*sizeof(T)))
176 ->NewPrimitiveValue(helper->isolate_, data_type, 0); 177 ->NewPrimitiveValue(helper->isolate_, data_type, 0);
177 v8::Handle<v8::Value> expected = Convert(value, helper->isolate_); 178 v8::Handle<v8::Value> expected = Convert(value, helper->isolate_);
178 helper->array_->Reset(); 179 helper->array_->Reset();
179 helper->array_->As<T*>()[index] = value; 180 helper->array_->As<T*>()[index] = value;
180 VerifyRead(descriptor, internal_field, *helper->array_, expected); 181 VerifyRead(descriptor, internal_field, helper->array_.get(), expected);
181 } 182 }
182 183
183 184
184 TEST(PrimitiveValueRead) { 185 TEST(PrimitiveValueRead) {
185 DescriptorTestHelper helper; 186 DescriptorTestHelper helper;
186 TestPrimitiveValue<int32_t>(203, v8::kDescriptorInt32Type, &helper); 187 TestPrimitiveValue<int32_t>(203, v8::kDescriptorInt32Type, &helper);
187 TestPrimitiveValue<float>(23.7f, v8::kDescriptorFloatType, &helper); 188 TestPrimitiveValue<float>(23.7f, v8::kDescriptorFloatType, &helper);
188 TestPrimitiveValue<double>(23.7, v8::kDescriptorDoubleType, &helper); 189 TestPrimitiveValue<double>(23.7, v8::kDescriptorDoubleType, &helper);
189 } 190 }
190 191
(...skipping 25 matching lines...) Expand all
216 case 4: 217 case 4:
217 descriptor = raw_descriptor->NewBitmaskCompare32( 218 descriptor = raw_descriptor->NewBitmaskCompare32(
218 helper->isolate_, 219 helper->isolate_,
219 static_cast<uint32_t>(bitmask), 220 static_cast<uint32_t>(bitmask),
220 static_cast<uint32_t>(compare_value)); 221 static_cast<uint32_t>(compare_value));
221 break; 222 break;
222 default: 223 default:
223 CHECK(false); 224 CHECK(false);
224 break; 225 break;
225 } 226 }
226 AlignedArray* array = *helper->array_; 227 AlignedArray* array = helper->array_.get();
227 array->Reset(); 228 array->Reset();
228 VerifyRead(descriptor, internal_field, array, v8::False(helper->isolate_)); 229 VerifyRead(descriptor, internal_field, array, v8::False(helper->isolate_));
229 array->As<T*>()[index] = compare_value; 230 array->As<T*>()[index] = compare_value;
230 VerifyRead(descriptor, internal_field, array, v8::True(helper->isolate_)); 231 VerifyRead(descriptor, internal_field, array, v8::True(helper->isolate_));
231 helper->array_->As<T*>()[index] = compare_value & bitmask; 232 helper->array_->As<T*>()[index] = compare_value & bitmask;
232 VerifyRead(descriptor, internal_field, array, v8::True(helper->isolate_)); 233 VerifyRead(descriptor, internal_field, array, v8::True(helper->isolate_));
233 } 234 }
234 235
235 236
236 TEST(BitmaskCompareRead) { 237 TEST(BitmaskCompareRead) {
237 DescriptorTestHelper helper; 238 DescriptorTestHelper helper;
238 TestBitmaskCompare<uint8_t>(0xf3, 0xa8, &helper); 239 TestBitmaskCompare<uint8_t>(0xf3, 0xa8, &helper);
239 TestBitmaskCompare<uint16_t>(0xfefe, 0x7d42, &helper); 240 TestBitmaskCompare<uint16_t>(0xfefe, 0x7d42, &helper);
240 TestBitmaskCompare<uint32_t>(0xfefeab18, 0x1234fdec, &helper); 241 TestBitmaskCompare<uint32_t>(0xfefeab18, 0x1234fdec, &helper);
241 } 242 }
242 243
243 244
244 TEST(PointerCompareRead) { 245 TEST(PointerCompareRead) {
245 DescriptorTestHelper helper; 246 DescriptorTestHelper helper;
246 v8::HandleScope handle_scope(helper.isolate_); 247 v8::HandleScope handle_scope(helper.isolate_);
247 int index = 35; 248 int index = 35;
248 int internal_field = 3; 249 int internal_field = 3;
249 void* ptr = helper.isolate_; 250 void* ptr = helper.isolate_;
250 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor = 251 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor =
251 OOD::NewInternalFieldDereference(helper.isolate_, internal_field) 252 OOD::NewInternalFieldDereference(helper.isolate_, internal_field)
252 ->NewRawShift(helper.isolate_, static_cast<uint16_t>(index*sizeof(ptr))) 253 ->NewRawShift(helper.isolate_, static_cast<uint16_t>(index*sizeof(ptr)))
253 ->NewPointerCompare(helper.isolate_, ptr); 254 ->NewPointerCompare(helper.isolate_, ptr);
254 AlignedArray* array = *helper.array_; 255 AlignedArray* array = helper.array_.get();
255 VerifyRead(descriptor, internal_field, array, v8::False(helper.isolate_)); 256 VerifyRead(descriptor, internal_field, array, v8::False(helper.isolate_));
256 array->As<uintptr_t*>()[index] = reinterpret_cast<uintptr_t>(ptr); 257 array->As<uintptr_t*>()[index] = reinterpret_cast<uintptr_t>(ptr);
257 VerifyRead(descriptor, internal_field, array, v8::True(helper.isolate_)); 258 VerifyRead(descriptor, internal_field, array, v8::True(helper.isolate_));
258 } 259 }
259 260
260 261
261 TEST(PointerDereferenceRead) { 262 TEST(PointerDereferenceRead) {
262 DescriptorTestHelper helper; 263 DescriptorTestHelper helper;
263 v8::HandleScope handle_scope(helper.isolate_); 264 v8::HandleScope handle_scope(helper.isolate_);
264 int first_index = 13; 265 int first_index = 13;
265 int internal_field = 7; 266 int internal_field = 7;
266 int second_index = 11; 267 int second_index = 11;
267 int pointed_to_index = 75; 268 int pointed_to_index = 75;
268 uint16_t expected = 0x1425; 269 uint16_t expected = 0x1425;
269 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor = 270 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor =
270 OOD::NewInternalFieldDereference(helper.isolate_, internal_field) 271 OOD::NewInternalFieldDereference(helper.isolate_, internal_field)
271 ->NewRawShift(helper.isolate_, first_index*kPointerSize) 272 ->NewRawShift(helper.isolate_, first_index*kPointerSize)
272 ->NewRawDereference(helper.isolate_) 273 ->NewRawDereference(helper.isolate_)
273 ->NewRawShift(helper.isolate_, 274 ->NewRawShift(helper.isolate_,
274 static_cast<uint16_t>(second_index*sizeof(int16_t))) 275 static_cast<uint16_t>(second_index*sizeof(int16_t)))
275 ->NewPrimitiveValue(helper.isolate_, v8::kDescriptorInt16Type, 0); 276 ->NewPrimitiveValue(helper.isolate_, v8::kDescriptorInt16Type, 0);
276 AlignedArray* array = *helper.array_; 277 AlignedArray* array = helper.array_.get();
277 array->As<uintptr_t**>()[first_index] = 278 array->As<uintptr_t**>()[first_index] =
278 &array->As<uintptr_t*>()[pointed_to_index]; 279 &array->As<uintptr_t*>()[pointed_to_index];
279 VerifyRead(descriptor, internal_field, array, v8::Integer::New(0)); 280 VerifyRead(descriptor, internal_field, array, v8::Integer::New(0));
280 second_index += pointed_to_index*sizeof(uintptr_t)/sizeof(uint16_t); 281 second_index += pointed_to_index*sizeof(uintptr_t)/sizeof(uint16_t);
281 array->As<uint16_t*>()[second_index] = expected; 282 array->As<uint16_t*>()[second_index] = expected;
282 VerifyRead(descriptor, internal_field, array, v8::Integer::New(expected)); 283 VerifyRead(descriptor, internal_field, array, v8::Integer::New(expected));
283 } 284 }
284 285
285 286
286 TEST(HandleDereferenceRead) { 287 TEST(HandleDereferenceRead) {
287 DescriptorTestHelper helper; 288 DescriptorTestHelper helper;
288 v8::HandleScope handle_scope(helper.isolate_); 289 v8::HandleScope handle_scope(helper.isolate_);
289 int index = 13; 290 int index = 13;
290 int internal_field = 0; 291 int internal_field = 0;
291 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor = 292 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor =
292 OOD::NewInternalFieldDereference(helper.isolate_, internal_field) 293 OOD::NewInternalFieldDereference(helper.isolate_, internal_field)
293 ->NewRawShift(helper.isolate_, index*kPointerSize) 294 ->NewRawShift(helper.isolate_, index*kPointerSize)
294 ->NewHandleDereference(helper.isolate_); 295 ->NewHandleDereference(helper.isolate_);
295 HandleArray* array = *helper.handle_array_; 296 HandleArray* array = helper.handle_array_.get();
296 v8::Handle<v8::String> expected = v8_str("whatever"); 297 v8::Handle<v8::String> expected = v8_str("whatever");
297 array->handles_[index].Reset(helper.isolate_, expected); 298 array->handles_[index].Reset(helper.isolate_, expected);
298 VerifyRead(descriptor, internal_field, array, expected); 299 VerifyRead(descriptor, internal_field, array, expected);
299 } 300 }
OLDNEW
« no previous file with comments | « test/cctest/test-debug.cc ('k') | test/cctest/test-decls.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698