OLD | NEW |
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 "vm/bootstrap_natives.h" | 5 #include "vm/bootstrap_natives.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
10 #include "vm/exceptions.h" | 10 #include "vm/exceptions.h" |
11 #include "vm/isolate.h" | 11 #include "vm/isolate.h" |
12 #include "vm/native_entry.h" | 12 #include "vm/native_entry.h" |
13 #include "vm/object.h" | 13 #include "vm/object.h" |
14 #include "vm/object_store.h" | 14 #include "vm/object_store.h" |
15 #include "vm/symbols.h" | 15 #include "vm/symbols.h" |
16 | 16 |
17 namespace dart { | 17 namespace dart { |
18 | 18 |
19 DEFINE_FLAG(bool, trace_intrinsified_natives, false, | 19 DEFINE_FLAG(bool, |
20 "Report if any of the intrinsified natives are called"); | 20 trace_intrinsified_natives, |
| 21 false, |
| 22 "Report if any of the intrinsified natives are called"); |
21 | 23 |
22 // Smi natives. | 24 // Smi natives. |
23 | 25 |
24 // Returns false if integer is in wrong representation, e.g., as is a Bigint | 26 // Returns false if integer is in wrong representation, e.g., as is a Bigint |
25 // when it could have been a Smi. | 27 // when it could have been a Smi. |
26 static bool CheckInteger(const Integer& i) { | 28 static bool CheckInteger(const Integer& i) { |
27 if (i.IsBigint()) { | 29 if (i.IsBigint()) { |
28 const Bigint& bigint = Bigint::Cast(i); | 30 const Bigint& bigint = Bigint::Cast(i); |
29 return !bigint.FitsIntoSmi() && !bigint.FitsIntoInt64(); | 31 return !bigint.FitsIntoSmi() && !bigint.FitsIntoInt64(); |
30 } | 32 } |
31 if (i.IsMint()) { | 33 if (i.IsMint()) { |
32 const Mint& mint = Mint::Cast(i); | 34 const Mint& mint = Mint::Cast(i); |
33 return !Smi::IsValid(mint.value()); | 35 return !Smi::IsValid(mint.value()); |
34 } | 36 } |
35 return true; | 37 return true; |
36 } | 38 } |
37 | 39 |
38 | 40 |
39 DEFINE_NATIVE_ENTRY(Integer_bitAndFromInteger, 2) { | 41 DEFINE_NATIVE_ENTRY(Integer_bitAndFromInteger, 2) { |
40 const Integer& right = Integer::CheckedHandle(arguments->NativeArgAt(0)); | 42 const Integer& right = Integer::CheckedHandle(arguments->NativeArgAt(0)); |
41 GET_NON_NULL_NATIVE_ARGUMENT(Integer, left, arguments->NativeArgAt(1)); | 43 GET_NON_NULL_NATIVE_ARGUMENT(Integer, left, arguments->NativeArgAt(1)); |
42 ASSERT(CheckInteger(right)); | 44 ASSERT(CheckInteger(right)); |
43 ASSERT(CheckInteger(left)); | 45 ASSERT(CheckInteger(left)); |
44 if (FLAG_trace_intrinsified_natives) { | 46 if (FLAG_trace_intrinsified_natives) { |
45 OS::Print("Integer_bitAndFromInteger %s & %s\n", | 47 OS::Print("Integer_bitAndFromInteger %s & %s\n", right.ToCString(), |
46 right.ToCString(), left.ToCString()); | 48 left.ToCString()); |
47 } | 49 } |
48 const Integer& result = Integer::Handle(left.BitOp(Token::kBIT_AND, right)); | 50 const Integer& result = Integer::Handle(left.BitOp(Token::kBIT_AND, right)); |
49 // A null result indicates that a bigint operation is required. | 51 // A null result indicates that a bigint operation is required. |
50 return result.IsNull() ? result.raw() : result.AsValidInteger(); | 52 return result.IsNull() ? result.raw() : result.AsValidInteger(); |
51 } | 53 } |
52 | 54 |
53 | 55 |
54 DEFINE_NATIVE_ENTRY(Integer_bitOrFromInteger, 2) { | 56 DEFINE_NATIVE_ENTRY(Integer_bitOrFromInteger, 2) { |
55 const Integer& right = Integer::CheckedHandle(arguments->NativeArgAt(0)); | 57 const Integer& right = Integer::CheckedHandle(arguments->NativeArgAt(0)); |
56 GET_NON_NULL_NATIVE_ARGUMENT(Integer, left, arguments->NativeArgAt(1)); | 58 GET_NON_NULL_NATIVE_ARGUMENT(Integer, left, arguments->NativeArgAt(1)); |
57 ASSERT(CheckInteger(right)); | 59 ASSERT(CheckInteger(right)); |
58 ASSERT(CheckInteger(left)); | 60 ASSERT(CheckInteger(left)); |
59 if (FLAG_trace_intrinsified_natives) { | 61 if (FLAG_trace_intrinsified_natives) { |
60 OS::Print("Integer_bitOrFromInteger %s | %s\n", | 62 OS::Print("Integer_bitOrFromInteger %s | %s\n", left.ToCString(), |
61 left.ToCString(), right.ToCString()); | 63 right.ToCString()); |
62 } | 64 } |
63 const Integer& result = Integer::Handle(left.BitOp(Token::kBIT_OR, right)); | 65 const Integer& result = Integer::Handle(left.BitOp(Token::kBIT_OR, right)); |
64 // A null result indicates that a bigint operation is required. | 66 // A null result indicates that a bigint operation is required. |
65 return result.IsNull() ? result.raw() : result.AsValidInteger(); | 67 return result.IsNull() ? result.raw() : result.AsValidInteger(); |
66 } | 68 } |
67 | 69 |
68 | 70 |
69 DEFINE_NATIVE_ENTRY(Integer_bitXorFromInteger, 2) { | 71 DEFINE_NATIVE_ENTRY(Integer_bitXorFromInteger, 2) { |
70 const Integer& right = Integer::CheckedHandle(arguments->NativeArgAt(0)); | 72 const Integer& right = Integer::CheckedHandle(arguments->NativeArgAt(0)); |
71 GET_NON_NULL_NATIVE_ARGUMENT(Integer, left, arguments->NativeArgAt(1)); | 73 GET_NON_NULL_NATIVE_ARGUMENT(Integer, left, arguments->NativeArgAt(1)); |
72 ASSERT(CheckInteger(right)); | 74 ASSERT(CheckInteger(right)); |
73 ASSERT(CheckInteger(left)); | 75 ASSERT(CheckInteger(left)); |
74 if (FLAG_trace_intrinsified_natives) { | 76 if (FLAG_trace_intrinsified_natives) { |
75 OS::Print("Integer_bitXorFromInteger %s ^ %s\n", | 77 OS::Print("Integer_bitXorFromInteger %s ^ %s\n", left.ToCString(), |
76 left.ToCString(), right.ToCString()); | 78 right.ToCString()); |
77 } | 79 } |
78 const Integer& result = Integer::Handle(left.BitOp(Token::kBIT_XOR, right)); | 80 const Integer& result = Integer::Handle(left.BitOp(Token::kBIT_XOR, right)); |
79 // A null result indicates that a bigint operation is required. | 81 // A null result indicates that a bigint operation is required. |
80 return result.IsNull() ? result.raw() : result.AsValidInteger(); | 82 return result.IsNull() ? result.raw() : result.AsValidInteger(); |
81 } | 83 } |
82 | 84 |
83 | 85 |
84 DEFINE_NATIVE_ENTRY(Integer_addFromInteger, 2) { | 86 DEFINE_NATIVE_ENTRY(Integer_addFromInteger, 2) { |
85 const Integer& right_int = Integer::CheckedHandle(arguments->NativeArgAt(0)); | 87 const Integer& right_int = Integer::CheckedHandle(arguments->NativeArgAt(0)); |
86 GET_NON_NULL_NATIVE_ARGUMENT(Integer, left_int, arguments->NativeArgAt(1)); | 88 GET_NON_NULL_NATIVE_ARGUMENT(Integer, left_int, arguments->NativeArgAt(1)); |
87 ASSERT(CheckInteger(right_int)); | 89 ASSERT(CheckInteger(right_int)); |
88 ASSERT(CheckInteger(left_int)); | 90 ASSERT(CheckInteger(left_int)); |
89 if (FLAG_trace_intrinsified_natives) { | 91 if (FLAG_trace_intrinsified_natives) { |
90 OS::Print("Integer_addFromInteger %s + %s\n", | 92 OS::Print("Integer_addFromInteger %s + %s\n", left_int.ToCString(), |
91 left_int.ToCString(), right_int.ToCString()); | 93 right_int.ToCString()); |
92 } | 94 } |
93 const Integer& result = | 95 const Integer& result = |
94 Integer::Handle(left_int.ArithmeticOp(Token::kADD, right_int)); | 96 Integer::Handle(left_int.ArithmeticOp(Token::kADD, right_int)); |
95 // A null result indicates that a bigint operation is required. | 97 // A null result indicates that a bigint operation is required. |
96 return result.IsNull() ? result.raw() : result.AsValidInteger(); | 98 return result.IsNull() ? result.raw() : result.AsValidInteger(); |
97 } | 99 } |
98 | 100 |
99 | 101 |
100 DEFINE_NATIVE_ENTRY(Integer_subFromInteger, 2) { | 102 DEFINE_NATIVE_ENTRY(Integer_subFromInteger, 2) { |
101 const Integer& right_int = Integer::CheckedHandle(arguments->NativeArgAt(0)); | 103 const Integer& right_int = Integer::CheckedHandle(arguments->NativeArgAt(0)); |
102 GET_NON_NULL_NATIVE_ARGUMENT(Integer, left_int, arguments->NativeArgAt(1)); | 104 GET_NON_NULL_NATIVE_ARGUMENT(Integer, left_int, arguments->NativeArgAt(1)); |
103 ASSERT(CheckInteger(right_int)); | 105 ASSERT(CheckInteger(right_int)); |
104 ASSERT(CheckInteger(left_int)); | 106 ASSERT(CheckInteger(left_int)); |
105 if (FLAG_trace_intrinsified_natives) { | 107 if (FLAG_trace_intrinsified_natives) { |
106 OS::Print("Integer_subFromInteger %s - %s\n", | 108 OS::Print("Integer_subFromInteger %s - %s\n", left_int.ToCString(), |
107 left_int.ToCString(), right_int.ToCString()); | 109 right_int.ToCString()); |
108 } | 110 } |
109 const Integer& result = | 111 const Integer& result = |
110 Integer::Handle(left_int.ArithmeticOp(Token::kSUB, right_int)); | 112 Integer::Handle(left_int.ArithmeticOp(Token::kSUB, right_int)); |
111 // A null result indicates that a bigint operation is required. | 113 // A null result indicates that a bigint operation is required. |
112 return result.IsNull() ? result.raw() : result.AsValidInteger(); | 114 return result.IsNull() ? result.raw() : result.AsValidInteger(); |
113 } | 115 } |
114 | 116 |
115 | 117 |
116 DEFINE_NATIVE_ENTRY(Integer_mulFromInteger, 2) { | 118 DEFINE_NATIVE_ENTRY(Integer_mulFromInteger, 2) { |
117 const Integer& right_int = Integer::CheckedHandle(arguments->NativeArgAt(0)); | 119 const Integer& right_int = Integer::CheckedHandle(arguments->NativeArgAt(0)); |
118 GET_NON_NULL_NATIVE_ARGUMENT(Integer, left_int, arguments->NativeArgAt(1)); | 120 GET_NON_NULL_NATIVE_ARGUMENT(Integer, left_int, arguments->NativeArgAt(1)); |
119 ASSERT(CheckInteger(right_int)); | 121 ASSERT(CheckInteger(right_int)); |
120 ASSERT(CheckInteger(left_int)); | 122 ASSERT(CheckInteger(left_int)); |
121 if (FLAG_trace_intrinsified_natives) { | 123 if (FLAG_trace_intrinsified_natives) { |
122 OS::Print("Integer_mulFromInteger %s * %s\n", | 124 OS::Print("Integer_mulFromInteger %s * %s\n", left_int.ToCString(), |
123 left_int.ToCString(), right_int.ToCString()); | 125 right_int.ToCString()); |
124 } | 126 } |
125 const Integer& result = | 127 const Integer& result = |
126 Integer::Handle(left_int.ArithmeticOp(Token::kMUL, right_int)); | 128 Integer::Handle(left_int.ArithmeticOp(Token::kMUL, right_int)); |
127 // A null result indicates that a bigint operation is required. | 129 // A null result indicates that a bigint operation is required. |
128 return result.IsNull() ? result.raw() : result.AsValidInteger(); | 130 return result.IsNull() ? result.raw() : result.AsValidInteger(); |
129 } | 131 } |
130 | 132 |
131 | 133 |
132 DEFINE_NATIVE_ENTRY(Integer_truncDivFromInteger, 2) { | 134 DEFINE_NATIVE_ENTRY(Integer_truncDivFromInteger, 2) { |
133 const Integer& right_int = Integer::CheckedHandle(arguments->NativeArgAt(0)); | 135 const Integer& right_int = Integer::CheckedHandle(arguments->NativeArgAt(0)); |
134 GET_NON_NULL_NATIVE_ARGUMENT(Integer, left_int, arguments->NativeArgAt(1)); | 136 GET_NON_NULL_NATIVE_ARGUMENT(Integer, left_int, arguments->NativeArgAt(1)); |
135 ASSERT(CheckInteger(right_int)); | 137 ASSERT(CheckInteger(right_int)); |
136 ASSERT(CheckInteger(left_int)); | 138 ASSERT(CheckInteger(left_int)); |
137 ASSERT(!right_int.IsZero()); | 139 ASSERT(!right_int.IsZero()); |
138 const Integer& result = | 140 const Integer& result = |
139 Integer::Handle(left_int.ArithmeticOp(Token::kTRUNCDIV, right_int)); | 141 Integer::Handle(left_int.ArithmeticOp(Token::kTRUNCDIV, right_int)); |
140 // A null result indicates that a bigint operation is required. | 142 // A null result indicates that a bigint operation is required. |
141 return result.IsNull() ? result.raw() : result.AsValidInteger(); | 143 return result.IsNull() ? result.raw() : result.AsValidInteger(); |
142 } | 144 } |
143 | 145 |
144 | 146 |
145 DEFINE_NATIVE_ENTRY(Integer_moduloFromInteger, 2) { | 147 DEFINE_NATIVE_ENTRY(Integer_moduloFromInteger, 2) { |
146 const Integer& right_int = Integer::CheckedHandle(arguments->NativeArgAt(0)); | 148 const Integer& right_int = Integer::CheckedHandle(arguments->NativeArgAt(0)); |
147 GET_NON_NULL_NATIVE_ARGUMENT(Integer, left_int, arguments->NativeArgAt(1)); | 149 GET_NON_NULL_NATIVE_ARGUMENT(Integer, left_int, arguments->NativeArgAt(1)); |
148 ASSERT(CheckInteger(right_int)); | 150 ASSERT(CheckInteger(right_int)); |
149 ASSERT(CheckInteger(left_int)); | 151 ASSERT(CheckInteger(left_int)); |
150 if (FLAG_trace_intrinsified_natives) { | 152 if (FLAG_trace_intrinsified_natives) { |
151 OS::Print("Integer_moduloFromInteger %s mod %s\n", | 153 OS::Print("Integer_moduloFromInteger %s mod %s\n", left_int.ToCString(), |
152 left_int.ToCString(), right_int.ToCString()); | 154 right_int.ToCString()); |
153 } | 155 } |
154 if (right_int.IsZero()) { | 156 if (right_int.IsZero()) { |
155 // Should have been caught before calling into runtime. | 157 // Should have been caught before calling into runtime. |
156 UNIMPLEMENTED(); | 158 UNIMPLEMENTED(); |
157 } | 159 } |
158 const Integer& result = | 160 const Integer& result = |
159 Integer::Handle(left_int.ArithmeticOp(Token::kMOD, right_int)); | 161 Integer::Handle(left_int.ArithmeticOp(Token::kMOD, right_int)); |
160 // A null result indicates that a bigint operation is required. | 162 // A null result indicates that a bigint operation is required. |
161 return result.IsNull() ? result.raw() : result.AsValidInteger(); | 163 return result.IsNull() ? result.raw() : result.AsValidInteger(); |
162 } | 164 } |
163 | 165 |
164 | 166 |
165 DEFINE_NATIVE_ENTRY(Integer_greaterThanFromInteger, 2) { | 167 DEFINE_NATIVE_ENTRY(Integer_greaterThanFromInteger, 2) { |
166 const Integer& right = Integer::CheckedHandle(arguments->NativeArgAt(0)); | 168 const Integer& right = Integer::CheckedHandle(arguments->NativeArgAt(0)); |
167 GET_NON_NULL_NATIVE_ARGUMENT(Integer, left, arguments->NativeArgAt(1)); | 169 GET_NON_NULL_NATIVE_ARGUMENT(Integer, left, arguments->NativeArgAt(1)); |
168 ASSERT(CheckInteger(right)); | 170 ASSERT(CheckInteger(right)); |
169 ASSERT(CheckInteger(left)); | 171 ASSERT(CheckInteger(left)); |
170 if (FLAG_trace_intrinsified_natives) { | 172 if (FLAG_trace_intrinsified_natives) { |
171 OS::Print("Integer_greaterThanFromInteger %s > %s\n", | 173 OS::Print("Integer_greaterThanFromInteger %s > %s\n", left.ToCString(), |
172 left.ToCString(), right.ToCString()); | 174 right.ToCString()); |
173 } | 175 } |
174 return Bool::Get(left.CompareWith(right) == 1).raw(); | 176 return Bool::Get(left.CompareWith(right) == 1).raw(); |
175 } | 177 } |
176 | 178 |
177 | 179 |
178 DEFINE_NATIVE_ENTRY(Integer_equalToInteger, 2) { | 180 DEFINE_NATIVE_ENTRY(Integer_equalToInteger, 2) { |
179 const Integer& left = Integer::CheckedHandle(arguments->NativeArgAt(0)); | 181 const Integer& left = Integer::CheckedHandle(arguments->NativeArgAt(0)); |
180 GET_NON_NULL_NATIVE_ARGUMENT(Integer, right, arguments->NativeArgAt(1)); | 182 GET_NON_NULL_NATIVE_ARGUMENT(Integer, right, arguments->NativeArgAt(1)); |
181 ASSERT(CheckInteger(left)); | 183 ASSERT(CheckInteger(left)); |
182 ASSERT(CheckInteger(right)); | 184 ASSERT(CheckInteger(right)); |
183 if (FLAG_trace_intrinsified_natives) { | 185 if (FLAG_trace_intrinsified_natives) { |
184 OS::Print("Integer_equalToInteger %s == %s\n", | 186 OS::Print("Integer_equalToInteger %s == %s\n", left.ToCString(), |
185 left.ToCString(), right.ToCString()); | 187 right.ToCString()); |
186 } | 188 } |
187 return Bool::Get(left.CompareWith(right) == 0).raw(); | 189 return Bool::Get(left.CompareWith(right) == 0).raw(); |
188 } | 190 } |
189 | 191 |
190 | 192 |
191 static RawInteger* ParseInteger(const String& value) { | 193 static RawInteger* ParseInteger(const String& value) { |
192 // Used by both Integer_parse and Integer_fromEnvironment. | 194 // Used by both Integer_parse and Integer_fromEnvironment. |
193 if (value.IsOneByteString()) { | 195 if (value.IsOneByteString()) { |
194 // Quick conversion for unpadded integers in strings. | 196 // Quick conversion for unpadded integers in strings. |
195 const intptr_t len = value.Length(); | 197 const intptr_t len = value.Length(); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 ASSERT(value.IsBigint()); | 284 ASSERT(value.IsBigint()); |
283 } | 285 } |
284 return Integer::null(); | 286 return Integer::null(); |
285 } | 287 } |
286 | 288 |
287 | 289 |
288 DEFINE_NATIVE_ENTRY(Smi_bitAndFromSmi, 2) { | 290 DEFINE_NATIVE_ENTRY(Smi_bitAndFromSmi, 2) { |
289 const Smi& left = Smi::CheckedHandle(arguments->NativeArgAt(0)); | 291 const Smi& left = Smi::CheckedHandle(arguments->NativeArgAt(0)); |
290 GET_NON_NULL_NATIVE_ARGUMENT(Smi, right, arguments->NativeArgAt(1)); | 292 GET_NON_NULL_NATIVE_ARGUMENT(Smi, right, arguments->NativeArgAt(1)); |
291 if (FLAG_trace_intrinsified_natives) { | 293 if (FLAG_trace_intrinsified_natives) { |
292 OS::Print("Smi_bitAndFromSmi %s & %s\n", | 294 OS::Print("Smi_bitAndFromSmi %s & %s\n", left.ToCString(), |
293 left.ToCString(), right.ToCString()); | 295 right.ToCString()); |
294 } | 296 } |
295 const Smi& left_value = Smi::Cast(left); | 297 const Smi& left_value = Smi::Cast(left); |
296 const Smi& right_value = Smi::Cast(right); | 298 const Smi& right_value = Smi::Cast(right); |
297 return Smi::New(left_value.Value() & right_value.Value()); | 299 return Smi::New(left_value.Value() & right_value.Value()); |
298 } | 300 } |
299 | 301 |
300 | 302 |
301 DEFINE_NATIVE_ENTRY(Smi_shrFromInt, 2) { | 303 DEFINE_NATIVE_ENTRY(Smi_shrFromInt, 2) { |
302 const Smi& amount = Smi::CheckedHandle(arguments->NativeArgAt(0)); | 304 const Smi& amount = Smi::CheckedHandle(arguments->NativeArgAt(0)); |
303 GET_NON_NULL_NATIVE_ARGUMENT(Integer, value, arguments->NativeArgAt(1)); | 305 GET_NON_NULL_NATIVE_ARGUMENT(Integer, value, arguments->NativeArgAt(1)); |
304 ASSERT(CheckInteger(amount)); | 306 ASSERT(CheckInteger(amount)); |
305 ASSERT(CheckInteger(value)); | 307 ASSERT(CheckInteger(value)); |
306 const Integer& result = Integer::Handle( | 308 const Integer& result = |
307 ShiftOperationHelper(Token::kSHR, value, amount)); | 309 Integer::Handle(ShiftOperationHelper(Token::kSHR, value, amount)); |
308 // A null result indicates that a bigint operation is required. | 310 // A null result indicates that a bigint operation is required. |
309 return result.IsNull() ? result.raw() : result.AsValidInteger(); | 311 return result.IsNull() ? result.raw() : result.AsValidInteger(); |
310 } | 312 } |
311 | 313 |
312 | 314 |
313 | |
314 DEFINE_NATIVE_ENTRY(Smi_shlFromInt, 2) { | 315 DEFINE_NATIVE_ENTRY(Smi_shlFromInt, 2) { |
315 const Smi& amount = Smi::CheckedHandle(arguments->NativeArgAt(0)); | 316 const Smi& amount = Smi::CheckedHandle(arguments->NativeArgAt(0)); |
316 GET_NON_NULL_NATIVE_ARGUMENT(Integer, value, arguments->NativeArgAt(1)); | 317 GET_NON_NULL_NATIVE_ARGUMENT(Integer, value, arguments->NativeArgAt(1)); |
317 ASSERT(CheckInteger(amount)); | 318 ASSERT(CheckInteger(amount)); |
318 ASSERT(CheckInteger(value)); | 319 ASSERT(CheckInteger(value)); |
319 if (FLAG_trace_intrinsified_natives) { | 320 if (FLAG_trace_intrinsified_natives) { |
320 OS::Print("Smi_shlFromInt: %s << %s\n", | 321 OS::Print("Smi_shlFromInt: %s << %s\n", value.ToCString(), |
321 value.ToCString(), amount.ToCString()); | 322 amount.ToCString()); |
322 } | 323 } |
323 const Integer& result = Integer::Handle( | 324 const Integer& result = |
324 ShiftOperationHelper(Token::kSHL, value, amount)); | 325 Integer::Handle(ShiftOperationHelper(Token::kSHL, value, amount)); |
325 // A null result indicates that a bigint operation is required. | 326 // A null result indicates that a bigint operation is required. |
326 return result.IsNull() ? result.raw() : result.AsValidInteger(); | 327 return result.IsNull() ? result.raw() : result.AsValidInteger(); |
327 } | 328 } |
328 | 329 |
329 | 330 |
330 DEFINE_NATIVE_ENTRY(Smi_bitNegate, 1) { | 331 DEFINE_NATIVE_ENTRY(Smi_bitNegate, 1) { |
331 const Smi& operand = Smi::CheckedHandle(arguments->NativeArgAt(0)); | 332 const Smi& operand = Smi::CheckedHandle(arguments->NativeArgAt(0)); |
332 if (FLAG_trace_intrinsified_natives) { | 333 if (FLAG_trace_intrinsified_natives) { |
333 OS::Print("Smi_bitNegate: %s\n", operand.ToCString()); | 334 OS::Print("Smi_bitNegate: %s\n", operand.ToCString()); |
334 } | 335 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 DEFINE_NATIVE_ENTRY(Bigint_allocate, 4) { | 411 DEFINE_NATIVE_ENTRY(Bigint_allocate, 4) { |
411 // First arg is null type arguments, since class Bigint is not parameterized. | 412 // First arg is null type arguments, since class Bigint is not parameterized. |
412 const Bool& neg = Bool::CheckedHandle(arguments->NativeArgAt(1)); | 413 const Bool& neg = Bool::CheckedHandle(arguments->NativeArgAt(1)); |
413 const Smi& used = Smi::CheckedHandle(arguments->NativeArgAt(2)); | 414 const Smi& used = Smi::CheckedHandle(arguments->NativeArgAt(2)); |
414 const TypedData& digits = TypedData::CheckedHandle(arguments->NativeArgAt(3)); | 415 const TypedData& digits = TypedData::CheckedHandle(arguments->NativeArgAt(3)); |
415 ASSERT(!digits.IsNull()); | 416 ASSERT(!digits.IsNull()); |
416 return Bigint::New(neg.value(), used.Value(), digits); | 417 return Bigint::New(neg.value(), used.Value(), digits); |
417 } | 418 } |
418 | 419 |
419 } // namespace dart | 420 } // namespace dart |
OLD | NEW |