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

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

Issue 1012333002: Keep zone cached in SnapshotReader to allow removing ZoneHandle(Isolate*) interface. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 9 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 | « runtime/vm/native_entry.h ('k') | runtime/vm/object.h » ('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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 "vm/native_entry_test.h" 5 #include "vm/native_entry_test.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/code_patcher.h" 8 #include "vm/code_patcher.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/native_entry.h" 10 #include "vm/native_entry.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 result += arg_value; 49 result += arg_value;
50 } 50 }
51 Dart_SetReturnValue(args, Dart_NewInteger(result)); 51 Dart_SetReturnValue(args, Dart_NewInteger(result));
52 } 52 }
53 53
54 54
55 // Test for accepting null arguments in native function. 55 // Test for accepting null arguments in native function.
56 // Arg0-4: 5 smis or null. 56 // Arg0-4: 5 smis or null.
57 // Result: a smi representing the sum of all non-null arguments. 57 // Result: a smi representing the sum of all non-null arguments.
58 void TestNonNullSmiSum(Dart_NativeArguments args) { 58 void TestNonNullSmiSum(Dart_NativeArguments args) {
59 Isolate* isolate = Isolate::Current(); 59 Isolate* isolate = Isolate::Current(); // Used by GET_NATIVE_ARGUMENT.
60 int64_t result = 0; 60 int64_t result = 0;
61 int arg_count = Dart_GetNativeArgumentCount(args); 61 int arg_count = Dart_GetNativeArgumentCount(args);
62 // Test the lower level macro GET_NATIVE_ARGUMENT. 62 // Test the lower level macro GET_NATIVE_ARGUMENT.
63 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 63 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
64 Zone* zone = Thread::Current()->zone(); // Used by GET_NATIVE_ARGUMENT.
64 for (int i = 0; i < arg_count; i++) { 65 for (int i = 0; i < arg_count; i++) {
65 Dart_Handle arg = Dart_GetNativeArgument(args, i); 66 Dart_Handle arg = Dart_GetNativeArgument(args, i);
66 GET_NATIVE_ARGUMENT(Integer, argument, arguments->NativeArgAt(i)); 67 GET_NATIVE_ARGUMENT(Integer, argument, arguments->NativeArgAt(i));
67 EXPECT(argument.IsInteger()); // May be null. 68 EXPECT(argument.IsInteger()); // May be null.
68 EXPECT_EQ(Api::UnwrapHandle(arg), argument.raw()); // May be null. 69 EXPECT_EQ(Api::UnwrapHandle(arg), argument.raw()); // May be null.
69 int64_t arg_value = -1; 70 int64_t arg_value = -1;
70 if (argument.IsNull()) { 71 if (argument.IsNull()) {
71 EXPECT_ERROR(Dart_IntegerToInt64(arg, &arg_value), 72 EXPECT_ERROR(Dart_IntegerToInt64(arg, &arg_value),
72 "Dart_IntegerToInt64 expects argument 'integer' " 73 "Dart_IntegerToInt64 expects argument 'integer' "
73 "to be non-null."); 74 "to be non-null.");
74 } else { 75 } else {
75 EXPECT_VALID(Dart_IntegerToInt64(arg, &arg_value)); 76 EXPECT_VALID(Dart_IntegerToInt64(arg, &arg_value));
76 EXPECT_EQ(arg_value, argument.AsInt64Value()); 77 EXPECT_EQ(arg_value, argument.AsInt64Value());
77 // Ignoring overflow in the addition below. 78 // Ignoring overflow in the addition below.
78 result += arg_value; 79 result += arg_value;
79 } 80 }
80 } 81 }
81 Dart_SetReturnValue(args, Dart_NewInteger(result)); 82 Dart_SetReturnValue(args, Dart_NewInteger(result));
82 } 83 }
83 84
84 } // namespace dart 85 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/native_entry.h ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698