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/object.h" | 5 #include "vm/object.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
11 #include "vm/code_generator.h" | 11 #include "vm/code_generator.h" |
12 #include "vm/code_index_table.h" | 12 #include "vm/code_index_table.h" |
13 #include "vm/code_patcher.h" | 13 #include "vm/code_patcher.h" |
14 #include "vm/compiler.h" | 14 #include "vm/compiler.h" |
15 #include "vm/compiler_stats.h" | 15 #include "vm/compiler_stats.h" |
16 #include "vm/class_finalizer.h" | 16 #include "vm/class_finalizer.h" |
17 #include "vm/dart.h" | 17 #include "vm/dart.h" |
18 #include "vm/dart_api_state.h" | 18 #include "vm/dart_api_state.h" |
19 #include "vm/dart_entry.h" | 19 #include "vm/dart_entry.h" |
20 #include "vm/debuginfo.h" | 20 #include "vm/debuginfo.h" |
| 21 #include "vm/double_conversion.h" |
21 #include "vm/exceptions.h" | 22 #include "vm/exceptions.h" |
22 #include "vm/growable_array.h" | 23 #include "vm/growable_array.h" |
23 #include "vm/heap.h" | 24 #include "vm/heap.h" |
24 #include "vm/object_store.h" | 25 #include "vm/object_store.h" |
25 #include "vm/parser.h" | 26 #include "vm/parser.h" |
26 #include "vm/runtime_entry.h" | 27 #include "vm/runtime_entry.h" |
27 #include "vm/scopes.h" | 28 #include "vm/scopes.h" |
28 #include "vm/timer.h" | 29 #include "vm/timer.h" |
29 #include "vm/unicode.h" | 30 #include "vm/unicode.h" |
30 | 31 |
(...skipping 6227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6258 } | 6259 } |
6259 | 6260 |
6260 | 6261 |
6261 const char* Double::ToCString() const { | 6262 const char* Double::ToCString() const { |
6262 if (isnan(value())) { | 6263 if (isnan(value())) { |
6263 return "NaN"; | 6264 return "NaN"; |
6264 } | 6265 } |
6265 if (isinf(value())) { | 6266 if (isinf(value())) { |
6266 return value() < 0 ? "-Infinity" : "Infinity"; | 6267 return value() < 0 ? "-Infinity" : "Infinity"; |
6267 } | 6268 } |
6268 const char* kFormat = "%f"; | 6269 const int kBufferSize = 128; |
6269 // Calculate the size of the string. | 6270 char* buffer = reinterpret_cast<char*>( |
6270 intptr_t len = OS::SNPrint(NULL, 0, kFormat, value()) + 1; | 6271 Isolate::Current()->current_zone()->Allocate(kBufferSize)); |
6271 char* chars = reinterpret_cast<char*>( | 6272 buffer[kBufferSize - 1] = '\0'; |
6272 Isolate::Current()->current_zone()->Allocate(len)); | 6273 DoubleToCString(value(), buffer, kBufferSize); |
6273 OS::SNPrint(chars, len, kFormat, value()); | 6274 return buffer; |
6274 // Eliminate trailing 0s, but leave one digit after '.'. | |
6275 // 'chars' is null terminated. | |
6276 for (intptr_t i = len - 2; i >= 1; i--) { | |
6277 if ((chars[i] == '0') && (chars[i - 1] != '.')) { | |
6278 chars[i] = '\0'; | |
6279 } else { | |
6280 break; | |
6281 } | |
6282 } | |
6283 return chars; | |
6284 } | 6275 } |
6285 | 6276 |
6286 | 6277 |
6287 bool Bigint::Equals(const Instance& other) const { | 6278 bool Bigint::Equals(const Instance& other) const { |
6288 if (this->raw() == other.raw()) { | 6279 if (this->raw() == other.raw()) { |
6289 // Both handles point to the same raw instance. | 6280 // Both handles point to the same raw instance. |
6290 return true; | 6281 return true; |
6291 } | 6282 } |
6292 | 6283 |
6293 if (!other.IsBigint() || other.IsNull()) { | 6284 if (!other.IsBigint() || other.IsNull()) { |
(...skipping 2037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8331 result.set_num_args_tested(num_args_tested); | 8322 result.set_num_args_tested(num_args_tested); |
8332 // Number of array elements in one test entry (num_args_tested + 1) | 8323 // Number of array elements in one test entry (num_args_tested + 1) |
8333 intptr_t len = num_args_tested + 1; | 8324 intptr_t len = num_args_tested + 1; |
8334 // IC data array must be null terminated (sentinel entry). | 8325 // IC data array must be null terminated (sentinel entry). |
8335 Array& ic_data = Array::Handle(Array::New(len, Heap::kOld)); | 8326 Array& ic_data = Array::Handle(Array::New(len, Heap::kOld)); |
8336 result.set_ic_data(ic_data); | 8327 result.set_ic_data(ic_data); |
8337 return result.raw(); | 8328 return result.raw(); |
8338 } | 8329 } |
8339 | 8330 |
8340 } // namespace dart | 8331 } // namespace dart |
OLD | NEW |