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

Side by Side Diff: runtime/vm/dart_api_impl_test.cc

Issue 1068823004: Fixes bug in LoadIndexedInstr on ARM. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 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 | « no previous file | runtime/vm/intermediate_language_arm.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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "bin/builtin.h" 5 #include "bin/builtin.h"
6 #include "include/dart_api.h" 6 #include "include/dart_api.h"
7 #include "include/dart_debugger_api.h" 7 #include "include/dart_debugger_api.h"
8 #include "include/dart_mirrors_api.h" 8 #include "include/dart_mirrors_api.h"
9 #include "include/dart_native_api.h" 9 #include "include/dart_native_api.h"
10 #include "platform/assert.h" 10 #include "platform/assert.h"
11 #include "platform/json.h" 11 #include "platform/json.h"
12 #include "platform/utils.h" 12 #include "platform/utils.h"
13 #include "vm/class_finalizer.h" 13 #include "vm/class_finalizer.h"
14 #include "vm/dart_api_impl.h" 14 #include "vm/dart_api_impl.h"
15 #include "vm/dart_api_state.h" 15 #include "vm/dart_api_state.h"
16 #include "vm/lockers.h" 16 #include "vm/lockers.h"
17 #include "vm/unit_test.h" 17 #include "vm/unit_test.h"
18 #include "vm/verifier.h" 18 #include "vm/verifier.h"
19 19
20 namespace dart { 20 namespace dart {
21 21
22 DECLARE_FLAG(bool, enable_type_checks); 22 DECLARE_FLAG(bool, enable_type_checks);
23 DECLARE_FLAG(int, optimization_counter_threshold);
23 DECLARE_FLAG(bool, verify_acquired_data); 24 DECLARE_FLAG(bool, verify_acquired_data);
24 25
25 TEST_CASE(ErrorHandleBasics) { 26 TEST_CASE(ErrorHandleBasics) {
26 const char* kScriptChars = 27 const char* kScriptChars =
27 "void testMain() {\n" 28 "void testMain() {\n"
28 " throw new Exception(\"bad news\");\n" 29 " throw new Exception(\"bad news\");\n"
29 "}\n"; 30 "}\n";
30 31
31 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 32 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
32 33
(...skipping 1702 matching lines...) Expand 10 before | Expand all | Expand 10 after
1735 result = Dart_Invoke(lib, NewString("main"), 0, NULL); 1736 result = Dart_Invoke(lib, NewString("main"), 0, NULL);
1736 EXPECT_VALID(result); 1737 EXPECT_VALID(result);
1737 1738
1738 for (intptr_t i = 0; i < kExtLength; i+=2) { 1739 for (intptr_t i = 0; i < kExtLength; i+=2) {
1739 EXPECT_EQ(0x24, data[i]); 1740 EXPECT_EQ(0x24, data[i]);
1740 EXPECT_EQ(0x28, data[i+1]); 1741 EXPECT_EQ(0x28, data[i+1]);
1741 } 1742 }
1742 } 1743 }
1743 1744
1744 1745
1746 static const intptr_t kOptExtLength = 16;
1747 static int8_t opt_data[kOptExtLength] = { 0x01, 0x02, 0x03, 0x04,
1748 0x05, 0x06, 0x07, 0x08,
1749 0x09, 0x0a, 0x0b, 0x0c,
1750 0x0d, 0x0e, 0x0f, 0x10, };
1751
1752 static void OptExternalByteDataNativeFunction(Dart_NativeArguments args) {
1753 Dart_EnterScope();
1754 Dart_Handle external_byte_data = Dart_NewExternalTypedData(
1755 Dart_TypedData_kByteData, opt_data, 16);
1756 EXPECT_VALID(external_byte_data);
1757 EXPECT_EQ(Dart_TypedData_kByteData,
1758 Dart_GetTypeOfTypedData(external_byte_data));
1759 Dart_SetReturnValue(args, external_byte_data);
1760 Dart_ExitScope();
1761 }
1762
1763
1764 static Dart_NativeFunction OptExternalByteDataNativeResolver(
1765 Dart_Handle name, int arg_count, bool* auto_setup_scope) {
1766 ASSERT(auto_setup_scope != NULL);
1767 *auto_setup_scope = false;
1768 return &OptExternalByteDataNativeFunction;
1769 }
1770
1771
1772 TEST_CASE(OptimizedExternalByteDataAccess) {
1773 const char* kScriptChars =
1774 "import 'dart:typed_data';\n"
1775 "class Expect {\n"
1776 " static equals(a, b) {\n"
1777 " if (a != b) {\n"
1778 " throw 'not equal. expected: $a, got: $b';\n"
1779 " }\n"
1780 " }\n"
1781 "}\n"
1782 "ByteData createExternalByteData() native 'CreateExternalByteData';"
1783 "access(ByteData a) {"
1784 " Expect.equals(0x04030201, a.getUint32(0, Endianness.LITTLE_ENDIAN));"
1785 " Expect.equals(0x08070605, a.getUint32(4, Endianness.LITTLE_ENDIAN));"
1786 " Expect.equals(0x0c0b0a09, a.getUint32(8, Endianness.LITTLE_ENDIAN));"
1787 " Expect.equals(0x100f0e0d, a.getUint32(12, Endianness.LITTLE_ENDIAN));"
1788 "}"
1789 "ByteData main() {"
1790 " var length = 16;"
1791 " var a = createExternalByteData();"
1792 " Expect.equals(length, a.lengthInBytes);"
1793 " for (int i = 0; i < 20; i++) {"
1794 " access(a);"
1795 " }"
1796 " return a;"
1797 "}\n";
1798 // Create a test library and Load up a test script in it.
1799 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
1800
1801 Dart_Handle result = Dart_SetNativeResolver(
1802 lib, &OptExternalByteDataNativeResolver, NULL);
1803 EXPECT_VALID(result);
1804
1805 // Invoke 'main' function.
1806 int old_oct = FLAG_optimization_counter_threshold;
1807 FLAG_optimization_counter_threshold = 5;
1808 result = Dart_Invoke(lib, NewString("main"), 0, NULL);
1809 EXPECT_VALID(result);
1810 FLAG_optimization_counter_threshold = old_oct;
1811 }
1812
1813
1745 static void TestTypedDataDirectAccess() { 1814 static void TestTypedDataDirectAccess() {
1746 Dart_Handle str = Dart_NewStringFromCString("junk"); 1815 Dart_Handle str = Dart_NewStringFromCString("junk");
1747 Dart_Handle byte_array = Dart_NewTypedData(Dart_TypedData_kUint8, 10); 1816 Dart_Handle byte_array = Dart_NewTypedData(Dart_TypedData_kUint8, 10);
1748 EXPECT_VALID(byte_array); 1817 EXPECT_VALID(byte_array);
1749 Dart_Handle result; 1818 Dart_Handle result;
1750 result = Dart_TypedDataAcquireData(byte_array, NULL, NULL, NULL); 1819 result = Dart_TypedDataAcquireData(byte_array, NULL, NULL, NULL);
1751 EXPECT_ERROR(result, "Dart_TypedDataAcquireData expects argument 'type'" 1820 EXPECT_ERROR(result, "Dart_TypedDataAcquireData expects argument 'type'"
1752 " to be non-null."); 1821 " to be non-null.");
1753 Dart_TypedData_Type type; 1822 Dart_TypedData_Type type;
1754 result = Dart_TypedDataAcquireData(byte_array, &type, NULL, NULL); 1823 result = Dart_TypedDataAcquireData(byte_array, &type, NULL, NULL);
(...skipping 7167 matching lines...) Expand 10 before | Expand all | Expand 10 after
8922 result = Dart_Invoke(lib, 8991 result = Dart_Invoke(lib,
8923 NewString("testView16"), 8992 NewString("testView16"),
8924 1, 8993 1,
8925 dart_args); 8994 dart_args);
8926 EXPECT_VALID(result); 8995 EXPECT_VALID(result);
8927 EXPECT(Dart_IsString(result)); 8996 EXPECT(Dart_IsString(result));
8928 } 8997 }
8929 } 8998 }
8930 8999
8931 } // namespace dart 9000 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698