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

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

Issue 140793003: 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,
16440 static_cast<int64_t>(low),
16441 static_cast<int64_t>(high));
16442 }
16443
16444
16445 THREADED_TEST(FixedUint8Array) {
16446 FixedTypedArrayTestHelper<i::FixedUint8Array, i::UINT8_ELEMENTS, uint8_t>(
16447 v8::kExternalUnsignedByteArray,
16448 0x0, 0xFF);
16449 }
16450
16451
16452 THREADED_TEST(FixedUint8ClampedArray) {
16453 FixedTypedArrayTestHelper<i::FixedUint8ClampedArray,
16454 i::UINT8_CLAMPED_ELEMENTS, uint8_t>(
16455 v8::kExternalPixelArray,
16456 0x0, 0xFF);
16457 }
16458
16459
16460 THREADED_TEST(FixedInt8Array) {
16461 FixedTypedArrayTestHelper<i::FixedInt8Array, i::INT8_ELEMENTS, int8_t>(
16462 v8::kExternalByteArray,
16463 -0x80, 0x7F);
16464 }
16465
16466
16467 THREADED_TEST(FixedUint16Array) {
16468 FixedTypedArrayTestHelper<i::FixedUint16Array, i::UINT16_ELEMENTS, uint16_t>(
16469 v8::kExternalUnsignedShortArray,
16470 0x0, 0xFFFF);
16471 }
16472
16473
16474 THREADED_TEST(FixedInt16Array) {
16475 FixedTypedArrayTestHelper<i::FixedInt16Array, i::INT16_ELEMENTS, int16_t>(
16476 v8::kExternalShortArray,
16477 -0x8000, 0x7FFF);
16478 }
16479
16480
16481 THREADED_TEST(FixedUint32Array) {
16482 FixedTypedArrayTestHelper<i::FixedUint32Array, i::UINT32_ELEMENTS, uint32_t>(
16483 v8::kExternalUnsignedIntArray,
16484 0x0, UINT_MAX);
16485 }
16486
16487
16488 THREADED_TEST(FixedInt32Array) {
16489 FixedTypedArrayTestHelper<i::FixedInt32Array, i::INT32_ELEMENTS, int32_t>(
16490 v8::kExternalIntArray,
16491 INT_MIN, INT_MAX);
16492 }
16493
16494
16495 THREADED_TEST(FixedFloat32Array) {
16496 FixedTypedArrayTestHelper<i::FixedFloat32Array, i::FLOAT32_ELEMENTS, float>(
16497 v8::kExternalFloatArray,
16498 -500, 500);
16499 }
16500
16501
16502 THREADED_TEST(FixedFloat64Array) {
16503 FixedTypedArrayTestHelper<i::FixedFloat64Array, i::FLOAT64_ELEMENTS, float>(
16504 v8::kExternalDoubleArray,
16505 -500, 500);
16506 }
16507
16508
16509 template <class ExternalArrayClass, class ElementType> 16401 template <class ExternalArrayClass, class ElementType>
16510 static void ExternalArrayTestHelper(v8::ExternalArrayType array_type, 16402 static void ExternalArrayTestHelper(v8::ExternalArrayType array_type,
16511 int64_t low, 16403 int64_t low,
16512 int64_t high) { 16404 int64_t high) {
16513 LocalContext context; 16405 LocalContext context;
16514 i::Isolate* isolate = CcTest::i_isolate(); 16406 i::Isolate* isolate = CcTest::i_isolate();
16515 i::Factory* factory = isolate->factory(); 16407 i::Factory* factory = isolate->factory();
16516 v8::HandleScope scope(context->GetIsolate()); 16408 v8::HandleScope scope(context->GetIsolate());
16517 const int kElementCount = 40; 16409 const int kElementCount = 40;
16518 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
21728 } 21620 }
21729 for (int i = 0; i < runs; i++) { 21621 for (int i = 0; i < runs; i++) {
21730 Local<String> expected; 21622 Local<String> expected;
21731 if (i != 0) { 21623 if (i != 0) {
21732 CHECK_EQ(v8_str("escape value"), values[i]); 21624 CHECK_EQ(v8_str("escape value"), values[i]);
21733 } else { 21625 } else {
21734 CHECK(values[i].IsEmpty()); 21626 CHECK(values[i].IsEmpty());
21735 } 21627 }
21736 } 21628 }
21737 } 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