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

Side by Side Diff: test/cctest/test-api.cc

Issue 231103002: Object::GetElements() and friends maybehandlification. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: FixedArray::UnionOfKeys() maybehandlified Created 6 years, 8 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 | « src/stub-cache.cc ('k') | test/cctest/test-heap.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 15623 matching lines...) Expand 10 before | Expand all | Expand 10 after
15634 obj_clone->Set(foo_string, 15634 obj_clone->Set(foo_string,
15635 v8::String::NewFromUtf8(isolate, "Hello")); 15635 v8::String::NewFromUtf8(isolate, "Hello"));
15636 CHECK(!obj->Get(foo_string)->IsUndefined()); 15636 CHECK(!obj->Get(foo_string)->IsUndefined());
15637 } 15637 }
15638 15638
15639 15639
15640 static void CheckElementValue(i::Isolate* isolate, 15640 static void CheckElementValue(i::Isolate* isolate,
15641 int expected, 15641 int expected,
15642 i::Handle<i::Object> obj, 15642 i::Handle<i::Object> obj,
15643 int offset) { 15643 int offset) {
15644 i::Object* element = *i::Object::GetElement(isolate, obj, offset); 15644 i::Object* element =
15645 *i::Object::GetElement(isolate, obj, offset).ToHandleChecked();
15645 CHECK_EQ(expected, i::Smi::cast(element)->value()); 15646 CHECK_EQ(expected, i::Smi::cast(element)->value());
15646 } 15647 }
15647 15648
15648 15649
15649 THREADED_TEST(PixelArray) { 15650 THREADED_TEST(PixelArray) {
15650 LocalContext context; 15651 LocalContext context;
15651 i::Isolate* isolate = CcTest::i_isolate(); 15652 i::Isolate* isolate = CcTest::i_isolate();
15652 i::Factory* factory = isolate->factory(); 15653 i::Factory* factory = isolate->factory();
15653 v8::HandleScope scope(context->GetIsolate()); 15654 v8::HandleScope scope(context->GetIsolate());
15654 const int kElementCount = 260; 15655 const int kElementCount = 260;
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
16271 // Check other boundary conditions, values and operations. 16272 // Check other boundary conditions, values and operations.
16272 result = CompileRun("for (var i = 0; i < 8; i++) {" 16273 result = CompileRun("for (var i = 0; i < 8; i++) {"
16273 " ext_array[7] = undefined;" 16274 " ext_array[7] = undefined;"
16274 "}" 16275 "}"
16275 "ext_array[7];"); 16276 "ext_array[7];");
16276 CHECK_EQ(0, result->Int32Value()); 16277 CHECK_EQ(0, result->Int32Value());
16277 if (array_type == v8::kExternalFloat64Array || 16278 if (array_type == v8::kExternalFloat64Array ||
16278 array_type == v8::kExternalFloat32Array) { 16279 array_type == v8::kExternalFloat32Array) {
16279 CHECK_EQ(static_cast<int>(i::OS::nan_value()), 16280 CHECK_EQ(static_cast<int>(i::OS::nan_value()),
16280 static_cast<int>( 16281 static_cast<int>(
16281 i::Object::GetElement(isolate, jsobj, 7)->Number())); 16282 i::Object::GetElement(
16283 isolate, jsobj, 7).ToHandleChecked()->Number()));
16282 } else { 16284 } else {
16283 CheckElementValue(isolate, 0, jsobj, 7); 16285 CheckElementValue(isolate, 0, jsobj, 7);
16284 } 16286 }
16285 16287
16286 result = CompileRun("for (var i = 0; i < 8; i++) {" 16288 result = CompileRun("for (var i = 0; i < 8; i++) {"
16287 " ext_array[6] = '2.3';" 16289 " ext_array[6] = '2.3';"
16288 "}" 16290 "}"
16289 "ext_array[6];"); 16291 "ext_array[6];");
16290 CHECK_EQ(2, result->Int32Value()); 16292 CHECK_EQ(2, result->Int32Value());
16291 CHECK_EQ(2, 16293 CHECK_EQ(2,
16292 static_cast<int>( 16294 static_cast<int>(
16293 i::Object::GetElement(isolate, jsobj, 6)->Number())); 16295 i::Object::GetElement(
16296 isolate, jsobj, 6).ToHandleChecked()->Number()));
16294 16297
16295 if (array_type != v8::kExternalFloat32Array && 16298 if (array_type != v8::kExternalFloat32Array &&
16296 array_type != v8::kExternalFloat64Array) { 16299 array_type != v8::kExternalFloat64Array) {
16297 // Though the specification doesn't state it, be explicit about 16300 // Though the specification doesn't state it, be explicit about
16298 // converting NaNs and +/-Infinity to zero. 16301 // converting NaNs and +/-Infinity to zero.
16299 result = CompileRun("for (var i = 0; i < 8; i++) {" 16302 result = CompileRun("for (var i = 0; i < 8; i++) {"
16300 " ext_array[i] = 5;" 16303 " ext_array[i] = 5;"
16301 "}" 16304 "}"
16302 "for (var i = 0; i < 8; i++) {" 16305 "for (var i = 0; i < 8; i++) {"
16303 " ext_array[i] = NaN;" 16306 " ext_array[i] = NaN;"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
16563 } 16566 }
16564 16567
16565 v8::Handle<v8::Object> obj = v8::Object::New(context->GetIsolate()); 16568 v8::Handle<v8::Object> obj = v8::Object::New(context->GetIsolate());
16566 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); 16569 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj);
16567 // Set the elements to be the external array. 16570 // Set the elements to be the external array.
16568 obj->SetIndexedPropertiesToExternalArrayData(array_data, 16571 obj->SetIndexedPropertiesToExternalArrayData(array_data,
16569 array_type, 16572 array_type,
16570 kElementCount); 16573 kElementCount);
16571 CHECK_EQ(1, 16574 CHECK_EQ(1,
16572 static_cast<int>( 16575 static_cast<int>(
16573 i::Object::GetElement(isolate, jsobj, 1)->Number())); 16576 i::Object::GetElement(
16577 isolate, jsobj, 1).ToHandleChecked()->Number()));
16574 16578
16575 ObjectWithExternalArrayTestHelper<ExternalArrayClass, ElementType>( 16579 ObjectWithExternalArrayTestHelper<ExternalArrayClass, ElementType>(
16576 context.local(), obj, kElementCount, array_type, low, high); 16580 context.local(), obj, kElementCount, array_type, low, high);
16577 16581
16578 v8::Handle<v8::Value> result; 16582 v8::Handle<v8::Value> result;
16579 16583
16580 // Test more complex manipulations which cause eax to contain values 16584 // Test more complex manipulations which cause eax to contain values
16581 // that won't be completely overwritten by loads from the arrays. 16585 // that won't be completely overwritten by loads from the arrays.
16582 // This catches bugs in the instructions used for the KeyedLoadIC 16586 // This catches bugs in the instructions used for the KeyedLoadIC
16583 // for byte and word types. 16587 // for byte and word types.
(...skipping 5808 matching lines...) Expand 10 before | Expand all | Expand 10 after
22392 "f.call(friend);"); 22396 "f.call(friend);");
22393 CHECK_EQ(2, named_access_count); 22397 CHECK_EQ(2, named_access_count);
22394 22398
22395 // Test access using Object.setPrototypeOf reflective method. 22399 // Test access using Object.setPrototypeOf reflective method.
22396 named_access_count = 0; 22400 named_access_count = 0;
22397 CompileRun("Object.setPrototypeOf(friend, {});"); 22401 CompileRun("Object.setPrototypeOf(friend, {});");
22398 CHECK_EQ(1, named_access_count); 22402 CHECK_EQ(1, named_access_count);
22399 CompileRun("Object.getPrototypeOf(friend);"); 22403 CompileRun("Object.getPrototypeOf(friend);");
22400 CHECK_EQ(2, named_access_count); 22404 CHECK_EQ(2, named_access_count);
22401 } 22405 }
OLDNEW
« no previous file with comments | « src/stub-cache.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698