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