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 "platform/globals.h" | 5 #include "platform/globals.h" |
6 | 6 |
7 #include "include/dart_tools_api.h" | 7 #include "include/dart_tools_api.h" |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
10 #include "vm/clustered_snapshot.h" | 10 #include "vm/clustered_snapshot.h" |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 ApiMessageReader api_reader(buffer, buffer_len); | 394 ApiMessageReader api_reader(buffer, buffer_len); |
395 Dart_CObject* root = api_reader.ReadMessage(); | 395 Dart_CObject* root = api_reader.ReadMessage(); |
396 EXPECT_NOTNULL(root); | 396 EXPECT_NOTNULL(root); |
397 EXPECT_EQ(Dart_CObject_kCapability, root->type); | 397 EXPECT_EQ(Dart_CObject_kCapability, root->type); |
398 int64_t id = root->value.as_capability.id; | 398 int64_t id = root->value.as_capability.id; |
399 EXPECT_EQ(12345, id); | 399 EXPECT_EQ(12345, id); |
400 CheckEncodeDecodeMessage(root); | 400 CheckEncodeDecodeMessage(root); |
401 } | 401 } |
402 | 402 |
403 TEST_CASE(SerializeBigint) { | 403 TEST_CASE(SerializeBigint) { |
| 404 if (Bigint::IsDisabled()) { |
| 405 return; |
| 406 } |
404 // Write snapshot with object content. | 407 // Write snapshot with object content. |
405 const char* cstr = "0x270FFFFFFFFFFFFFD8F0"; | 408 const char* cstr = "0x270FFFFFFFFFFFFFD8F0"; |
406 const String& str = String::Handle(String::New(cstr)); | 409 const String& str = String::Handle(String::New(cstr)); |
407 Bigint& bigint = Bigint::Handle(); | 410 Bigint& bigint = Bigint::Handle(); |
408 bigint ^= Integer::NewCanonical(str); | 411 bigint ^= Integer::NewCanonical(str); |
409 uint8_t* buffer; | 412 uint8_t* buffer; |
410 MessageWriter writer(&buffer, &zone_allocator, &zone_deallocator, true); | 413 MessageWriter writer(&buffer, &zone_allocator, &zone_deallocator, true); |
411 writer.WriteMessage(bigint); | 414 writer.WriteMessage(bigint); |
412 intptr_t buffer_len = writer.BytesWritten(); | 415 intptr_t buffer_len = writer.BytesWritten(); |
413 | 416 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 Bigint& bigint = Bigint::Handle(); | 469 Bigint& bigint = Bigint::Handle(); |
467 bigint ^= Bigint::NewFromCString(bigint_value); | 470 bigint ^= Bigint::NewFromCString(bigint_value); |
468 Dart_CObject* bigint_cobject = SerializeAndDeserializeBigint(bigint); | 471 Dart_CObject* bigint_cobject = SerializeAndDeserializeBigint(bigint); |
469 EXPECT_EQ(Dart_CObject_kBigint, bigint_cobject->type); | 472 EXPECT_EQ(Dart_CObject_kBigint, bigint_cobject->type); |
470 char* hex_value = TestCase::BigintToHexValue(bigint_cobject); | 473 char* hex_value = TestCase::BigintToHexValue(bigint_cobject); |
471 EXPECT_STREQ(bigint_value, hex_value); | 474 EXPECT_STREQ(bigint_value, hex_value); |
472 free(hex_value); | 475 free(hex_value); |
473 } | 476 } |
474 | 477 |
475 TEST_CASE(SerializeBigint2) { | 478 TEST_CASE(SerializeBigint2) { |
| 479 if (Bigint::IsDisabled()) { |
| 480 return; |
| 481 } |
476 CheckBigint("0x0"); | 482 CheckBigint("0x0"); |
477 CheckBigint("0x1"); | 483 CheckBigint("0x1"); |
478 CheckBigint("-0x1"); | 484 CheckBigint("-0x1"); |
479 CheckBigint("0x11111111111111111111"); | 485 CheckBigint("0x11111111111111111111"); |
480 CheckBigint("-0x11111111111111111111"); | 486 CheckBigint("-0x11111111111111111111"); |
481 CheckBigint("0x9876543210987654321098765432109876543210"); | 487 CheckBigint("0x9876543210987654321098765432109876543210"); |
482 CheckBigint("-0x9876543210987654321098765432109876543210"); | 488 CheckBigint("-0x9876543210987654321098765432109876543210"); |
483 } | 489 } |
484 | 490 |
485 TEST_CASE(SerializeSingletons) { | 491 TEST_CASE(SerializeSingletons) { |
(...skipping 2577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3063 StackZone zone(Thread::Current()); | 3069 StackZone zone(Thread::Current()); |
3064 uint8_t* buffer; | 3070 uint8_t* buffer; |
3065 MessageWriter writer(&buffer, &zone_allocator, &zone_deallocator, true); | 3071 MessageWriter writer(&buffer, &zone_allocator, &zone_deallocator, true); |
3066 writer.WriteInlinedObjectHeader(kOmittedObjectId); | 3072 writer.WriteInlinedObjectHeader(kOmittedObjectId); |
3067 // For performance, we'd like single-byte headers when ids are omitted. | 3073 // For performance, we'd like single-byte headers when ids are omitted. |
3068 // If this starts failing, consider renumbering the snapshot ids. | 3074 // If this starts failing, consider renumbering the snapshot ids. |
3069 EXPECT_EQ(1, writer.BytesWritten()); | 3075 EXPECT_EQ(1, writer.BytesWritten()); |
3070 } | 3076 } |
3071 | 3077 |
3072 } // namespace dart | 3078 } // namespace dart |
OLD | NEW |