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 "include/dart_debugger_api.h" | 5 #include "include/dart_debugger_api.h" |
6 #include "platform/assert.h" | 6 #include "platform/assert.h" |
7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
10 #include "vm/dart_api_message.h" | 10 #include "vm/dart_api_message.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 | 52 |
53 static uint8_t* malloc_allocator( | 53 static uint8_t* malloc_allocator( |
54 uint8_t* ptr, intptr_t old_size, intptr_t new_size) { | 54 uint8_t* ptr, intptr_t old_size, intptr_t new_size) { |
55 return reinterpret_cast<uint8_t*>(realloc(ptr, new_size)); | 55 return reinterpret_cast<uint8_t*>(realloc(ptr, new_size)); |
56 } | 56 } |
57 | 57 |
58 | 58 |
59 static uint8_t* zone_allocator( | 59 static uint8_t* zone_allocator( |
60 uint8_t* ptr, intptr_t old_size, intptr_t new_size) { | 60 uint8_t* ptr, intptr_t old_size, intptr_t new_size) { |
61 StackZone* zone = Isolate::Current()->current_zone(); | 61 Zone* zone = Isolate::Current()->current_zone(); |
62 return zone->Realloc<uint8_t>(ptr, old_size, new_size); | 62 return zone->Realloc<uint8_t>(ptr, old_size, new_size); |
63 } | 63 } |
64 | 64 |
65 | 65 |
66 // Compare two Dart_CObject object graphs rooted in first and | 66 // Compare two Dart_CObject object graphs rooted in first and |
67 // second. The second graph will be destroyed by this operation no matter | 67 // second. The second graph will be destroyed by this operation no matter |
68 // whether the graphs are equal or not. | 68 // whether the graphs are equal or not. |
69 static void CompareDartCObjects(Dart_CObject* first, Dart_CObject* second) { | 69 static void CompareDartCObjects(Dart_CObject* first, Dart_CObject* second) { |
70 // Return immediately if entering a cycle. | 70 // Return immediately if entering a cycle. |
71 if (second->type == Dart_CObject::kNumberOfTypes) return; | 71 if (second->type == Dart_CObject::kNumberOfTypes) return; |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 Bigint& serialized_bigint = Bigint::Handle(); | 409 Bigint& serialized_bigint = Bigint::Handle(); |
410 serialized_bigint ^= reader.ReadObject(); | 410 serialized_bigint ^= reader.ReadObject(); |
411 const char* str1 = BigintOperations::ToHexCString(bigint, allocator); | 411 const char* str1 = BigintOperations::ToHexCString(bigint, allocator); |
412 const char* str2 = | 412 const char* str2 = |
413 BigintOperations::ToHexCString(serialized_bigint, allocator); | 413 BigintOperations::ToHexCString(serialized_bigint, allocator); |
414 EXPECT_STREQ(str1, str2); | 414 EXPECT_STREQ(str1, str2); |
415 free(const_cast<char*>(str1)); | 415 free(const_cast<char*>(str1)); |
416 free(const_cast<char*>(str2)); | 416 free(const_cast<char*>(str2)); |
417 | 417 |
418 // Read object back from the snapshot into a C structure. | 418 // Read object back from the snapshot into a C structure. |
419 ApiNativeScope scope; | |
420 ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator); | 419 ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator); |
421 Dart_CObject* root = api_reader.ReadMessage(); | 420 Dart_CObject* root = api_reader.ReadMessage(); |
422 // Bigint not supported. | 421 // Bigint not supported. |
423 EXPECT_NOTNULL(root); | 422 EXPECT_NOTNULL(root); |
424 CheckEncodeDecodeMessage(root); | 423 CheckEncodeDecodeMessage(root); |
425 return root; | 424 return root; |
426 } | 425 } |
427 | 426 |
428 | 427 |
429 void CheckBigint(const char* bigint_value) { | 428 void CheckBigint(const char* bigint_value) { |
430 StackZone zone(Isolate::Current()); | 429 StackZone zone(Isolate::Current()); |
| 430 ApiNativeScope scope; |
431 | 431 |
432 Bigint& bigint = Bigint::Handle(); | 432 Bigint& bigint = Bigint::Handle(); |
433 bigint ^= BigintOperations::NewFromCString(bigint_value); | 433 bigint ^= BigintOperations::NewFromCString(bigint_value); |
434 Dart_CObject* bigint_cobject = SerializeAndDeserializeBigint(bigint); | 434 Dart_CObject* bigint_cobject = SerializeAndDeserializeBigint(bigint); |
435 EXPECT_EQ(Dart_CObject::kBigint, bigint_cobject->type); | 435 EXPECT_EQ(Dart_CObject::kBigint, bigint_cobject->type); |
436 if (bigint_value[0] == '0') { | 436 if (bigint_value[0] == '0') { |
437 EXPECT_STREQ(bigint_value + 2, bigint_cobject->value.as_bigint); | 437 EXPECT_STREQ(bigint_value + 2, bigint_cobject->value.as_bigint); |
438 } else { | 438 } else { |
439 EXPECT_EQ('-', bigint_value[0]); | 439 EXPECT_EQ('-', bigint_value[0]); |
440 EXPECT_EQ('-', bigint_cobject->value.as_bigint[0]); | 440 EXPECT_EQ('-', bigint_cobject->value.as_bigint[0]); |
(...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1966 EXPECT(Dart_ErrorHasException(result)); | 1966 EXPECT(Dart_ErrorHasException(result)); |
1967 EXPECT_SUBSTRING("Exception: nulltruefalse1234563.14[]100123456789\n", | 1967 EXPECT_SUBSTRING("Exception: nulltruefalse1234563.14[]100123456789\n", |
1968 Dart_GetError(result)); | 1968 Dart_GetError(result)); |
1969 | 1969 |
1970 Dart_ExitScope(); | 1970 Dart_ExitScope(); |
1971 } | 1971 } |
1972 | 1972 |
1973 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 1973 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
1974 | 1974 |
1975 } // namespace dart | 1975 } // namespace dart |
OLD | NEW |