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

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

Issue 132233012: Revert "Implement in-heap backing store for typed arrays." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 11 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/x64/lithium-x64.cc ('k') | no next file » | 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 16095 matching lines...) Expand 10 before | Expand all | Expand 10 after
16106 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); 16106 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj);
16107 i::Isolate* isolate = jsobj->GetIsolate(); 16107 i::Isolate* isolate = jsobj->GetIsolate();
16108 obj->Set(v8_str("field"), 16108 obj->Set(v8_str("field"),
16109 v8::Int32::New(reinterpret_cast<v8::Isolate*>(isolate), 1503)); 16109 v8::Int32::New(reinterpret_cast<v8::Isolate*>(isolate), 1503));
16110 context->Global()->Set(v8_str("ext_array"), obj); 16110 context->Global()->Set(v8_str("ext_array"), obj);
16111 v8::Handle<v8::Value> result = CompileRun("ext_array.field"); 16111 v8::Handle<v8::Value> result = CompileRun("ext_array.field");
16112 CHECK_EQ(1503, result->Int32Value()); 16112 CHECK_EQ(1503, result->Int32Value());
16113 result = CompileRun("ext_array[1]"); 16113 result = CompileRun("ext_array[1]");
16114 CHECK_EQ(1, result->Int32Value()); 16114 CHECK_EQ(1, result->Int32Value());
16115 16115
16116 // Check pass through of assigned smis
16117 result = CompileRun("var sum = 0;"
16118 "for (var i = 0; i < 8; i++) {"
16119 " sum += ext_array[i] = ext_array[i] = -i;"
16120 "}"
16121 "sum;");
16122 CHECK_EQ(-28, result->Int32Value());
16123
16116 // Check assigned smis 16124 // Check assigned smis
16117 result = CompileRun("for (var i = 0; i < 8; i++) {" 16125 result = CompileRun("for (var i = 0; i < 8; i++) {"
16118 " ext_array[i] = i;" 16126 " ext_array[i] = i;"
16119 "}" 16127 "}"
16120 "var sum = 0;" 16128 "var sum = 0;"
16121 "for (var i = 0; i < 8; i++) {" 16129 "for (var i = 0; i < 8; i++) {"
16122 " sum += ext_array[i];" 16130 " sum += ext_array[i];"
16123 "}" 16131 "}"
16124 "sum;"); 16132 "sum;");
16125
16126 CHECK_EQ(28, result->Int32Value()); 16133 CHECK_EQ(28, result->Int32Value());
16127 // Check pass through of assigned smis
16128 result = CompileRun("var sum = 0;"
16129 "for (var i = 0; i < 8; i++) {"
16130 " sum += ext_array[i] = ext_array[i] = -i;"
16131 "}"
16132 "sum;");
16133 CHECK_EQ(-28, result->Int32Value());
16134
16135 16134
16136 // Check assigned smis in reverse order 16135 // Check assigned smis in reverse order
16137 result = CompileRun("for (var i = 8; --i >= 0; ) {" 16136 result = CompileRun("for (var i = 8; --i >= 0; ) {"
16138 " ext_array[i] = i;" 16137 " ext_array[i] = i;"
16139 "}" 16138 "}"
16140 "var sum = 0;" 16139 "var sum = 0;"
16141 "for (var i = 0; i < 8; i++) {" 16140 "for (var i = 0; i < 8; i++) {"
16142 " sum += ext_array[i];" 16141 " sum += ext_array[i];"
16143 "}" 16142 "}"
16144 "sum;"); 16143 "sum;");
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
16392 "js_array.__proto__ = ext_array;" 16391 "js_array.__proto__ = ext_array;"
16393 "js_array.concat(ext_array);"); 16392 "js_array.concat(ext_array);");
16394 CHECK_EQ(77, v8::Object::Cast(*result)->Get(v8_str("0"))->Int32Value()); 16393 CHECK_EQ(77, v8::Object::Cast(*result)->Get(v8_str("0"))->Int32Value());
16395 CHECK_EQ(23, v8::Object::Cast(*result)->Get(v8_str("1"))->Int32Value()); 16394 CHECK_EQ(23, v8::Object::Cast(*result)->Get(v8_str("1"))->Int32Value());
16396 16395
16397 result = CompileRun("ext_array[1] = 23;"); 16396 result = CompileRun("ext_array[1] = 23;");
16398 CHECK_EQ(23, result->Int32Value()); 16397 CHECK_EQ(23, result->Int32Value());
16399 } 16398 }
16400 16399
16401 16400
16402 template <class FixedTypedArrayClass,
16403 i::ElementsKind elements_kind,
16404 class ElementType>
16405 static void FixedTypedArrayTestHelper(
16406 v8::ExternalArrayType array_type,
16407 ElementType low,
16408 ElementType high) {
16409 i::FLAG_allow_natives_syntax = true;
16410 LocalContext context;
16411 i::Isolate* isolate = CcTest::i_isolate();
16412 i::Factory* factory = isolate->factory();
16413 v8::HandleScope scope(context->GetIsolate());
16414 const int kElementCount = 260;
16415 i::Handle<FixedTypedArrayClass> fixed_array =
16416 i::Handle<FixedTypedArrayClass>::cast(
16417 factory->NewFixedTypedArray(kElementCount, array_type));
16418 CHECK_EQ(FixedTypedArrayClass::kInstanceType,
16419 fixed_array->map()->instance_type());
16420 CHECK_EQ(kElementCount, fixed_array->length());
16421 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
16422 for (int i = 0; i < kElementCount; i++) {
16423 fixed_array->set(i, static_cast<ElementType>(i));
16424 }
16425 // Force GC to trigger verification.
16426 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
16427 for (int i = 0; i < kElementCount; i++) {
16428 CHECK_EQ(static_cast<int64_t>(static_cast<ElementType>(i)),
16429 static_cast<int64_t>(fixed_array->get_scalar(i)));
16430 }
16431 v8::Handle<v8::Object> obj = v8::Object::New(CcTest::isolate());
16432 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj);
16433 i::Handle<i::Map> fixed_array_map =
16434 isolate->factory()->GetElementsTransitionMap(jsobj, elements_kind);
16435 jsobj->set_map(*fixed_array_map);
16436 jsobj->set_elements(*fixed_array);
16437
16438 ObjectWithExternalArrayTestHelper<FixedTypedArrayClass, ElementType>(
16439 context.local(), obj, kElementCount, array_type, low, high);
16440 }
16441
16442
16443 THREADED_TEST(FixedUint8Array) {
16444 FixedTypedArrayTestHelper<i::FixedUint8Array, i::UINT8_ELEMENTS, uint8_t>(
16445 v8::kExternalUnsignedByteArray,
16446 0x0, 0xFF);
16447 }
16448
16449
16450 THREADED_TEST(FixedUint8ClampedArray) {
16451 FixedTypedArrayTestHelper<i::FixedUint8ClampedArray,
16452 i::UINT8_CLAMPED_ELEMENTS, uint8_t>(
16453 v8::kExternalPixelArray,
16454 0x0, 0xFF);
16455 }
16456
16457
16458 THREADED_TEST(FixedInt8Array) {
16459 FixedTypedArrayTestHelper<i::FixedInt8Array, i::INT8_ELEMENTS, int8_t>(
16460 v8::kExternalByteArray,
16461 -0x80, 0x7F);
16462 }
16463
16464
16465 THREADED_TEST(FixedUint16Array) {
16466 FixedTypedArrayTestHelper<i::FixedUint16Array, i::UINT16_ELEMENTS, uint16_t>(
16467 v8::kExternalUnsignedShortArray,
16468 0x0, 0xFFFF);
16469 }
16470
16471
16472 THREADED_TEST(FixedInt16Array) {
16473 FixedTypedArrayTestHelper<i::FixedInt16Array, i::INT16_ELEMENTS, int16_t>(
16474 v8::kExternalShortArray,
16475 -0x8000, 0x7FFF);
16476 }
16477
16478
16479 THREADED_TEST(FixedUint32Array) {
16480 FixedTypedArrayTestHelper<i::FixedUint32Array, i::UINT32_ELEMENTS, uint32_t>(
16481 v8::kExternalUnsignedIntArray,
16482 0x0, 0xFFFFFFFF);
16483 }
16484
16485
16486 THREADED_TEST(FixedInt32Array) {
16487 FixedTypedArrayTestHelper<i::FixedInt32Array, i::INT32_ELEMENTS, int32_t>(
16488 v8::kExternalIntArray,
16489 -0x80000000, 0x7FFFFFFF);
16490 }
16491
16492
16493 THREADED_TEST(FixedFloat32Array) {
16494 FixedTypedArrayTestHelper<i::FixedFloat32Array, i::FLOAT32_ELEMENTS, float>(
16495 v8::kExternalFloatArray,
16496 -500, 500);
16497 }
16498
16499
16500 THREADED_TEST(FixedFloat64Array) {
16501 FixedTypedArrayTestHelper<i::FixedFloat64Array, i::FLOAT64_ELEMENTS, float>(
16502 v8::kExternalDoubleArray,
16503 -500, 500);
16504 }
16505
16506
16507 template <class ExternalArrayClass, class ElementType> 16401 template <class ExternalArrayClass, class ElementType>
16508 static void ExternalArrayTestHelper(v8::ExternalArrayType array_type, 16402 static void ExternalArrayTestHelper(v8::ExternalArrayType array_type,
16509 int64_t low, 16403 int64_t low,
16510 int64_t high) { 16404 int64_t high) {
16511 LocalContext context; 16405 LocalContext context;
16512 i::Isolate* isolate = CcTest::i_isolate(); 16406 i::Isolate* isolate = CcTest::i_isolate();
16513 i::Factory* factory = isolate->factory(); 16407 i::Factory* factory = isolate->factory();
16514 v8::HandleScope scope(context->GetIsolate()); 16408 v8::HandleScope scope(context->GetIsolate());
16515 const int kElementCount = 40; 16409 const int kElementCount = 40;
16516 int element_size = ExternalArrayElementSize(array_type); 16410 int element_size = ExternalArrayElementSize(array_type);
(...skipping 5209 matching lines...) Expand 10 before | Expand all | Expand 10 after
21726 } 21620 }
21727 for (int i = 0; i < runs; i++) { 21621 for (int i = 0; i < runs; i++) {
21728 Local<String> expected; 21622 Local<String> expected;
21729 if (i != 0) { 21623 if (i != 0) {
21730 CHECK_EQ(v8_str("escape value"), values[i]); 21624 CHECK_EQ(v8_str("escape value"), values[i]);
21731 } else { 21625 } else {
21732 CHECK(values[i].IsEmpty()); 21626 CHECK(values[i].IsEmpty());
21733 } 21627 }
21734 } 21628 }
21735 } 21629 }
OLDNEW
« no previous file with comments | « src/x64/lithium-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698