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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl_test.cc
===================================================================
--- runtime/vm/dart_api_impl_test.cc (revision 44897)
+++ runtime/vm/dart_api_impl_test.cc (working copy)
@@ -20,6 +20,7 @@
namespace dart {
DECLARE_FLAG(bool, enable_type_checks);
+DECLARE_FLAG(int, optimization_counter_threshold);
DECLARE_FLAG(bool, verify_acquired_data);
TEST_CASE(ErrorHandleBasics) {
@@ -1742,6 +1743,74 @@
}
+static const intptr_t kOptExtLength = 16;
+static int8_t opt_data[kOptExtLength] = { 0x01, 0x02, 0x03, 0x04,
+ 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0a, 0x0b, 0x0c,
+ 0x0d, 0x0e, 0x0f, 0x10, };
+
+static void OptExternalByteDataNativeFunction(Dart_NativeArguments args) {
+ Dart_EnterScope();
+ Dart_Handle external_byte_data = Dart_NewExternalTypedData(
+ Dart_TypedData_kByteData, opt_data, 16);
+ EXPECT_VALID(external_byte_data);
+ EXPECT_EQ(Dart_TypedData_kByteData,
+ Dart_GetTypeOfTypedData(external_byte_data));
+ Dart_SetReturnValue(args, external_byte_data);
+ Dart_ExitScope();
+}
+
+
+static Dart_NativeFunction OptExternalByteDataNativeResolver(
+ Dart_Handle name, int arg_count, bool* auto_setup_scope) {
+ ASSERT(auto_setup_scope != NULL);
+ *auto_setup_scope = false;
+ return &OptExternalByteDataNativeFunction;
+}
+
+
+TEST_CASE(OptimizedExternalByteDataAccess) {
+ const char* kScriptChars =
+ "import 'dart:typed_data';\n"
+ "class Expect {\n"
+ " static equals(a, b) {\n"
+ " if (a != b) {\n"
+ " throw 'not equal. expected: $a, got: $b';\n"
+ " }\n"
+ " }\n"
+ "}\n"
+ "ByteData createExternalByteData() native 'CreateExternalByteData';"
+ "access(ByteData a) {"
+ " Expect.equals(0x04030201, a.getUint32(0, Endianness.LITTLE_ENDIAN));"
+ " Expect.equals(0x08070605, a.getUint32(4, Endianness.LITTLE_ENDIAN));"
+ " Expect.equals(0x0c0b0a09, a.getUint32(8, Endianness.LITTLE_ENDIAN));"
+ " Expect.equals(0x100f0e0d, a.getUint32(12, Endianness.LITTLE_ENDIAN));"
+ "}"
+ "ByteData main() {"
+ " var length = 16;"
+ " var a = createExternalByteData();"
+ " Expect.equals(length, a.lengthInBytes);"
+ " for (int i = 0; i < 20; i++) {"
+ " access(a);"
+ " }"
+ " return a;"
+ "}\n";
+ // Create a test library and Load up a test script in it.
+ Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
+
+ Dart_Handle result = Dart_SetNativeResolver(
+ lib, &OptExternalByteDataNativeResolver, NULL);
+ EXPECT_VALID(result);
+
+ // Invoke 'main' function.
+ int old_oct = FLAG_optimization_counter_threshold;
+ FLAG_optimization_counter_threshold = 5;
+ result = Dart_Invoke(lib, NewString("main"), 0, NULL);
+ EXPECT_VALID(result);
+ FLAG_optimization_counter_threshold = old_oct;
+}
+
+
static void TestTypedDataDirectAccess() {
Dart_Handle str = Dart_NewStringFromCString("junk");
Dart_Handle byte_array = Dart_NewTypedData(Dart_TypedData_kUint8, 10);
« 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