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_debugger_api.h" | 7 #include "include/dart_debugger_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/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 const bool result = writer.WriteCMessage(root); | 144 const bool result = writer.WriteCMessage(root); |
145 EXPECT_EQ(false, result); | 145 EXPECT_EQ(false, result); |
146 } | 146 } |
147 | 147 |
148 | 148 |
149 TEST_CASE(SerializeNull) { | 149 TEST_CASE(SerializeNull) { |
150 StackZone zone(Isolate::Current()); | 150 StackZone zone(Isolate::Current()); |
151 | 151 |
152 // Write snapshot with object content. | 152 // Write snapshot with object content. |
153 uint8_t* buffer; | 153 uint8_t* buffer; |
154 MessageWriter writer(&buffer, &zone_allocator); | 154 MessageWriter writer(&buffer, &zone_allocator, true); |
155 const Object& null_object = Object::Handle(); | 155 const Object& null_object = Object::Handle(); |
156 writer.WriteMessage(null_object); | 156 writer.WriteMessage(null_object); |
157 intptr_t buffer_len = writer.BytesWritten(); | 157 intptr_t buffer_len = writer.BytesWritten(); |
158 | 158 |
159 // Read object back from the snapshot. | 159 // Read object back from the snapshot. |
160 SnapshotReader reader(buffer, buffer_len, | 160 SnapshotReader reader(buffer, buffer_len, |
161 Snapshot::kMessage, Isolate::Current()); | 161 Snapshot::kMessage, Isolate::Current()); |
162 const Object& serialized_object = Object::Handle(reader.ReadObject()); | 162 const Object& serialized_object = Object::Handle(reader.ReadObject()); |
163 EXPECT(Equals(null_object, serialized_object)); | 163 EXPECT(Equals(null_object, serialized_object)); |
164 | 164 |
165 // Read object back from the snapshot into a C structure. | 165 // Read object back from the snapshot into a C structure. |
166 ApiNativeScope scope; | 166 ApiNativeScope scope; |
167 ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator); | 167 ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator); |
168 Dart_CObject* root = api_reader.ReadMessage(); | 168 Dart_CObject* root = api_reader.ReadMessage(); |
169 EXPECT_NOTNULL(root); | 169 EXPECT_NOTNULL(root); |
170 EXPECT_EQ(Dart_CObject_kNull, root->type); | 170 EXPECT_EQ(Dart_CObject_kNull, root->type); |
171 CheckEncodeDecodeMessage(root); | 171 CheckEncodeDecodeMessage(root); |
172 } | 172 } |
173 | 173 |
174 | 174 |
175 TEST_CASE(SerializeSmi1) { | 175 TEST_CASE(SerializeSmi1) { |
176 StackZone zone(Isolate::Current()); | 176 StackZone zone(Isolate::Current()); |
177 | 177 |
178 // Write snapshot with object content. | 178 // Write snapshot with object content. |
179 uint8_t* buffer; | 179 uint8_t* buffer; |
180 MessageWriter writer(&buffer, &zone_allocator); | 180 MessageWriter writer(&buffer, &zone_allocator, true); |
181 const Smi& smi = Smi::Handle(Smi::New(124)); | 181 const Smi& smi = Smi::Handle(Smi::New(124)); |
182 writer.WriteMessage(smi); | 182 writer.WriteMessage(smi); |
183 intptr_t buffer_len = writer.BytesWritten(); | 183 intptr_t buffer_len = writer.BytesWritten(); |
184 | 184 |
185 // Read object back from the snapshot. | 185 // Read object back from the snapshot. |
186 SnapshotReader reader(buffer, buffer_len, | 186 SnapshotReader reader(buffer, buffer_len, |
187 Snapshot::kMessage, Isolate::Current()); | 187 Snapshot::kMessage, Isolate::Current()); |
188 const Object& serialized_object = Object::Handle(reader.ReadObject()); | 188 const Object& serialized_object = Object::Handle(reader.ReadObject()); |
189 EXPECT(Equals(smi, serialized_object)); | 189 EXPECT(Equals(smi, serialized_object)); |
190 | 190 |
191 // Read object back from the snapshot into a C structure. | 191 // Read object back from the snapshot into a C structure. |
192 ApiNativeScope scope; | 192 ApiNativeScope scope; |
193 ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator); | 193 ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator); |
194 Dart_CObject* root = api_reader.ReadMessage(); | 194 Dart_CObject* root = api_reader.ReadMessage(); |
195 EXPECT_NOTNULL(root); | 195 EXPECT_NOTNULL(root); |
196 EXPECT_EQ(Dart_CObject_kInt32, root->type); | 196 EXPECT_EQ(Dart_CObject_kInt32, root->type); |
197 EXPECT_EQ(smi.Value(), root->value.as_int32); | 197 EXPECT_EQ(smi.Value(), root->value.as_int32); |
198 CheckEncodeDecodeMessage(root); | 198 CheckEncodeDecodeMessage(root); |
199 } | 199 } |
200 | 200 |
201 | 201 |
202 TEST_CASE(SerializeSmi2) { | 202 TEST_CASE(SerializeSmi2) { |
203 StackZone zone(Isolate::Current()); | 203 StackZone zone(Isolate::Current()); |
204 | 204 |
205 // Write snapshot with object content. | 205 // Write snapshot with object content. |
206 uint8_t* buffer; | 206 uint8_t* buffer; |
207 MessageWriter writer(&buffer, &zone_allocator); | 207 MessageWriter writer(&buffer, &zone_allocator, true); |
208 const Smi& smi = Smi::Handle(Smi::New(-1)); | 208 const Smi& smi = Smi::Handle(Smi::New(-1)); |
209 writer.WriteMessage(smi); | 209 writer.WriteMessage(smi); |
210 intptr_t buffer_len = writer.BytesWritten(); | 210 intptr_t buffer_len = writer.BytesWritten(); |
211 | 211 |
212 // Read object back from the snapshot. | 212 // Read object back from the snapshot. |
213 SnapshotReader reader(buffer, buffer_len, | 213 SnapshotReader reader(buffer, buffer_len, |
214 Snapshot::kMessage, Isolate::Current()); | 214 Snapshot::kMessage, Isolate::Current()); |
215 const Object& serialized_object = Object::Handle(reader.ReadObject()); | 215 const Object& serialized_object = Object::Handle(reader.ReadObject()); |
216 EXPECT(Equals(smi, serialized_object)); | 216 EXPECT(Equals(smi, serialized_object)); |
217 | 217 |
218 // Read object back from the snapshot into a C structure. | 218 // Read object back from the snapshot into a C structure. |
219 ApiNativeScope scope; | 219 ApiNativeScope scope; |
220 ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator); | 220 ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator); |
221 Dart_CObject* root = api_reader.ReadMessage(); | 221 Dart_CObject* root = api_reader.ReadMessage(); |
222 EXPECT_NOTNULL(root); | 222 EXPECT_NOTNULL(root); |
223 EXPECT_EQ(Dart_CObject_kInt32, root->type); | 223 EXPECT_EQ(Dart_CObject_kInt32, root->type); |
224 EXPECT_EQ(smi.Value(), root->value.as_int32); | 224 EXPECT_EQ(smi.Value(), root->value.as_int32); |
225 CheckEncodeDecodeMessage(root); | 225 CheckEncodeDecodeMessage(root); |
226 } | 226 } |
227 | 227 |
228 | 228 |
229 Dart_CObject* SerializeAndDeserializeMint(const Mint& mint) { | 229 Dart_CObject* SerializeAndDeserializeMint(const Mint& mint) { |
230 // Write snapshot with object content. | 230 // Write snapshot with object content. |
231 uint8_t* buffer; | 231 uint8_t* buffer; |
232 MessageWriter writer(&buffer, &zone_allocator); | 232 MessageWriter writer(&buffer, &zone_allocator, true); |
233 writer.WriteMessage(mint); | 233 writer.WriteMessage(mint); |
234 intptr_t buffer_len = writer.BytesWritten(); | 234 intptr_t buffer_len = writer.BytesWritten(); |
235 | 235 |
236 // Read object back from the snapshot. | 236 // Read object back from the snapshot. |
237 SnapshotReader reader(buffer, buffer_len, | 237 SnapshotReader reader(buffer, buffer_len, |
238 Snapshot::kMessage, Isolate::Current()); | 238 Snapshot::kMessage, Isolate::Current()); |
239 const Object& serialized_object = Object::Handle(reader.ReadObject()); | 239 const Object& serialized_object = Object::Handle(reader.ReadObject()); |
240 EXPECT(serialized_object.IsMint()); | 240 EXPECT(serialized_object.IsMint()); |
241 | 241 |
242 // Read object back from the snapshot into a C structure. | 242 // Read object back from the snapshot into a C structure. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 // Min negative mint + 1. | 292 // Min negative mint + 1. |
293 CheckMint(kMinInt64 + 1); | 293 CheckMint(kMinInt64 + 1); |
294 } | 294 } |
295 | 295 |
296 | 296 |
297 TEST_CASE(SerializeDouble) { | 297 TEST_CASE(SerializeDouble) { |
298 StackZone zone(Isolate::Current()); | 298 StackZone zone(Isolate::Current()); |
299 | 299 |
300 // Write snapshot with object content. | 300 // Write snapshot with object content. |
301 uint8_t* buffer; | 301 uint8_t* buffer; |
302 MessageWriter writer(&buffer, &zone_allocator); | 302 MessageWriter writer(&buffer, &zone_allocator, true); |
303 const Double& dbl = Double::Handle(Double::New(101.29)); | 303 const Double& dbl = Double::Handle(Double::New(101.29)); |
304 writer.WriteMessage(dbl); | 304 writer.WriteMessage(dbl); |
305 intptr_t buffer_len = writer.BytesWritten(); | 305 intptr_t buffer_len = writer.BytesWritten(); |
306 | 306 |
307 // Read object back from the snapshot. | 307 // Read object back from the snapshot. |
308 SnapshotReader reader(buffer, buffer_len, | 308 SnapshotReader reader(buffer, buffer_len, |
309 Snapshot::kMessage, Isolate::Current()); | 309 Snapshot::kMessage, Isolate::Current()); |
310 const Object& serialized_object = Object::Handle(reader.ReadObject()); | 310 const Object& serialized_object = Object::Handle(reader.ReadObject()); |
311 EXPECT(Equals(dbl, serialized_object)); | 311 EXPECT(Equals(dbl, serialized_object)); |
312 | 312 |
313 // Read object back from the snapshot into a C structure. | 313 // Read object back from the snapshot into a C structure. |
314 ApiNativeScope scope; | 314 ApiNativeScope scope; |
315 ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator); | 315 ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator); |
316 Dart_CObject* root = api_reader.ReadMessage(); | 316 Dart_CObject* root = api_reader.ReadMessage(); |
317 EXPECT_NOTNULL(root); | 317 EXPECT_NOTNULL(root); |
318 EXPECT_EQ(Dart_CObject_kDouble, root->type); | 318 EXPECT_EQ(Dart_CObject_kDouble, root->type); |
319 EXPECT_EQ(dbl.value(), root->value.as_double); | 319 EXPECT_EQ(dbl.value(), root->value.as_double); |
320 CheckEncodeDecodeMessage(root); | 320 CheckEncodeDecodeMessage(root); |
321 } | 321 } |
322 | 322 |
323 | 323 |
324 TEST_CASE(SerializeTrue) { | 324 TEST_CASE(SerializeTrue) { |
325 StackZone zone(Isolate::Current()); | 325 StackZone zone(Isolate::Current()); |
326 | 326 |
327 // Write snapshot with true object. | 327 // Write snapshot with true object. |
328 uint8_t* buffer; | 328 uint8_t* buffer; |
329 MessageWriter writer(&buffer, &zone_allocator); | 329 MessageWriter writer(&buffer, &zone_allocator, true); |
330 const Bool& bl = Bool::True(); | 330 const Bool& bl = Bool::True(); |
331 writer.WriteMessage(bl); | 331 writer.WriteMessage(bl); |
332 intptr_t buffer_len = writer.BytesWritten(); | 332 intptr_t buffer_len = writer.BytesWritten(); |
333 | 333 |
334 // Read object back from the snapshot. | 334 // Read object back from the snapshot. |
335 SnapshotReader reader(buffer, buffer_len, | 335 SnapshotReader reader(buffer, buffer_len, |
336 Snapshot::kMessage, Isolate::Current()); | 336 Snapshot::kMessage, Isolate::Current()); |
337 const Object& serialized_object = Object::Handle(reader.ReadObject()); | 337 const Object& serialized_object = Object::Handle(reader.ReadObject()); |
338 fprintf(stderr, "%s / %s\n", bl.ToCString(), serialized_object.ToCString()); | 338 fprintf(stderr, "%s / %s\n", bl.ToCString(), serialized_object.ToCString()); |
339 | 339 |
340 EXPECT(Equals(bl, serialized_object)); | 340 EXPECT(Equals(bl, serialized_object)); |
341 | 341 |
342 // Read object back from the snapshot into a C structure. | 342 // Read object back from the snapshot into a C structure. |
343 ApiNativeScope scope; | 343 ApiNativeScope scope; |
344 ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator); | 344 ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator); |
345 Dart_CObject* root = api_reader.ReadMessage(); | 345 Dart_CObject* root = api_reader.ReadMessage(); |
346 EXPECT_NOTNULL(root); | 346 EXPECT_NOTNULL(root); |
347 EXPECT_EQ(Dart_CObject_kBool, root->type); | 347 EXPECT_EQ(Dart_CObject_kBool, root->type); |
348 EXPECT_EQ(true, root->value.as_bool); | 348 EXPECT_EQ(true, root->value.as_bool); |
349 CheckEncodeDecodeMessage(root); | 349 CheckEncodeDecodeMessage(root); |
350 } | 350 } |
351 | 351 |
352 | 352 |
353 TEST_CASE(SerializeFalse) { | 353 TEST_CASE(SerializeFalse) { |
354 StackZone zone(Isolate::Current()); | 354 StackZone zone(Isolate::Current()); |
355 | 355 |
356 // Write snapshot with false object. | 356 // Write snapshot with false object. |
357 uint8_t* buffer; | 357 uint8_t* buffer; |
358 MessageWriter writer(&buffer, &zone_allocator); | 358 MessageWriter writer(&buffer, &zone_allocator, true); |
359 const Bool& bl = Bool::False(); | 359 const Bool& bl = Bool::False(); |
360 writer.WriteMessage(bl); | 360 writer.WriteMessage(bl); |
361 intptr_t buffer_len = writer.BytesWritten(); | 361 intptr_t buffer_len = writer.BytesWritten(); |
362 | 362 |
363 // Read object back from the snapshot. | 363 // Read object back from the snapshot. |
364 SnapshotReader reader(buffer, buffer_len, | 364 SnapshotReader reader(buffer, buffer_len, |
365 Snapshot::kMessage, Isolate::Current()); | 365 Snapshot::kMessage, Isolate::Current()); |
366 const Object& serialized_object = Object::Handle(reader.ReadObject()); | 366 const Object& serialized_object = Object::Handle(reader.ReadObject()); |
367 EXPECT(Equals(bl, serialized_object)); | 367 EXPECT(Equals(bl, serialized_object)); |
368 | 368 |
(...skipping 11 matching lines...) Expand all Loading... |
380 static uword allocator(intptr_t size) { | 380 static uword allocator(intptr_t size) { |
381 return reinterpret_cast<uword>(malloc(size)); | 381 return reinterpret_cast<uword>(malloc(size)); |
382 } | 382 } |
383 | 383 |
384 | 384 |
385 TEST_CASE(SerializeBigint) { | 385 TEST_CASE(SerializeBigint) { |
386 StackZone zone(Isolate::Current()); | 386 StackZone zone(Isolate::Current()); |
387 | 387 |
388 // Write snapshot with object content. | 388 // Write snapshot with object content. |
389 uint8_t* buffer; | 389 uint8_t* buffer; |
390 MessageWriter writer(&buffer, &zone_allocator); | 390 MessageWriter writer(&buffer, &zone_allocator, true); |
391 const char* cstr = "0x270FFFFFFFFFFFFFD8F0"; | 391 const char* cstr = "0x270FFFFFFFFFFFFFD8F0"; |
392 const String& str = String::Handle(String::New(cstr)); | 392 const String& str = String::Handle(String::New(cstr)); |
393 Bigint& bigint = Bigint::Handle(); | 393 Bigint& bigint = Bigint::Handle(); |
394 bigint ^= Integer::NewCanonical(str); | 394 bigint ^= Integer::NewCanonical(str); |
395 writer.WriteMessage(bigint); | 395 writer.WriteMessage(bigint); |
396 intptr_t buffer_len = writer.BytesWritten(); | 396 intptr_t buffer_len = writer.BytesWritten(); |
397 | 397 |
398 // Read object back from the snapshot. | 398 // Read object back from the snapshot. |
399 SnapshotReader reader(buffer, buffer_len, | 399 SnapshotReader reader(buffer, buffer_len, |
400 Snapshot::kMessage, Isolate::Current()); | 400 Snapshot::kMessage, Isolate::Current()); |
(...skipping 11 matching lines...) Expand all Loading... |
412 char* hex_value = TestCase::BigintToHexValue(root); | 412 char* hex_value = TestCase::BigintToHexValue(root); |
413 EXPECT_STREQ(cstr, hex_value); | 413 EXPECT_STREQ(cstr, hex_value); |
414 free(hex_value); | 414 free(hex_value); |
415 CheckEncodeDecodeMessage(root); | 415 CheckEncodeDecodeMessage(root); |
416 } | 416 } |
417 | 417 |
418 | 418 |
419 Dart_CObject* SerializeAndDeserializeBigint(const Bigint& bigint) { | 419 Dart_CObject* SerializeAndDeserializeBigint(const Bigint& bigint) { |
420 // Write snapshot with object content. | 420 // Write snapshot with object content. |
421 uint8_t* buffer; | 421 uint8_t* buffer; |
422 MessageWriter writer(&buffer, &zone_allocator); | 422 MessageWriter writer(&buffer, &zone_allocator, true); |
423 writer.WriteMessage(bigint); | 423 writer.WriteMessage(bigint); |
424 intptr_t buffer_len = writer.BytesWritten(); | 424 intptr_t buffer_len = writer.BytesWritten(); |
425 | 425 |
426 // Read object back from the snapshot. | 426 // Read object back from the snapshot. |
427 SnapshotReader reader(buffer, buffer_len, | 427 SnapshotReader reader(buffer, buffer_len, |
428 Snapshot::kMessage, Isolate::Current()); | 428 Snapshot::kMessage, Isolate::Current()); |
429 Bigint& serialized_bigint = Bigint::Handle(); | 429 Bigint& serialized_bigint = Bigint::Handle(); |
430 serialized_bigint ^= reader.ReadObject(); | 430 serialized_bigint ^= reader.ReadObject(); |
431 const char* str1 = bigint.ToHexCString(allocator); | 431 const char* str1 = bigint.ToHexCString(allocator); |
432 const char* str2 = serialized_bigint.ToHexCString(allocator); | 432 const char* str2 = serialized_bigint.ToHexCString(allocator); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 CheckBigint("-0x1"); | 464 CheckBigint("-0x1"); |
465 CheckBigint("0x11111111111111111111"); | 465 CheckBigint("0x11111111111111111111"); |
466 CheckBigint("-0x11111111111111111111"); | 466 CheckBigint("-0x11111111111111111111"); |
467 CheckBigint("0x9876543210987654321098765432109876543210"); | 467 CheckBigint("0x9876543210987654321098765432109876543210"); |
468 CheckBigint("-0x9876543210987654321098765432109876543210"); | 468 CheckBigint("-0x9876543210987654321098765432109876543210"); |
469 } | 469 } |
470 | 470 |
471 TEST_CASE(SerializeSingletons) { | 471 TEST_CASE(SerializeSingletons) { |
472 // Write snapshot with object content. | 472 // Write snapshot with object content. |
473 uint8_t* buffer; | 473 uint8_t* buffer; |
474 MessageWriter writer(&buffer, &malloc_allocator); | 474 MessageWriter writer(&buffer, &malloc_allocator, true); |
475 writer.WriteObject(Object::class_class()); | 475 writer.WriteObject(Object::class_class()); |
476 writer.WriteObject(Object::type_arguments_class()); | 476 writer.WriteObject(Object::type_arguments_class()); |
477 writer.WriteObject(Object::function_class()); | 477 writer.WriteObject(Object::function_class()); |
478 writer.WriteObject(Object::field_class()); | 478 writer.WriteObject(Object::field_class()); |
479 writer.WriteObject(Object::token_stream_class()); | 479 writer.WriteObject(Object::token_stream_class()); |
480 writer.WriteObject(Object::script_class()); | 480 writer.WriteObject(Object::script_class()); |
481 writer.WriteObject(Object::library_class()); | 481 writer.WriteObject(Object::library_class()); |
482 writer.WriteObject(Object::code_class()); | 482 writer.WriteObject(Object::code_class()); |
483 writer.WriteObject(Object::instructions_class()); | 483 writer.WriteObject(Object::instructions_class()); |
484 writer.WriteObject(Object::pc_descriptors_class()); | 484 writer.WriteObject(Object::pc_descriptors_class()); |
(...skipping 21 matching lines...) Expand all Loading... |
506 | 506 |
507 free(buffer); | 507 free(buffer); |
508 } | 508 } |
509 | 509 |
510 | 510 |
511 static void TestString(const char* cstr) { | 511 static void TestString(const char* cstr) { |
512 StackZone zone(Isolate::Current()); | 512 StackZone zone(Isolate::Current()); |
513 EXPECT(Utf8::IsValid(reinterpret_cast<const uint8_t*>(cstr), strlen(cstr))); | 513 EXPECT(Utf8::IsValid(reinterpret_cast<const uint8_t*>(cstr), strlen(cstr))); |
514 // Write snapshot with object content. | 514 // Write snapshot with object content. |
515 uint8_t* buffer; | 515 uint8_t* buffer; |
516 MessageWriter writer(&buffer, &zone_allocator); | 516 MessageWriter writer(&buffer, &zone_allocator, true); |
517 String& str = String::Handle(String::New(cstr)); | 517 String& str = String::Handle(String::New(cstr)); |
518 writer.WriteMessage(str); | 518 writer.WriteMessage(str); |
519 intptr_t buffer_len = writer.BytesWritten(); | 519 intptr_t buffer_len = writer.BytesWritten(); |
520 | 520 |
521 // Read object back from the snapshot. | 521 // Read object back from the snapshot. |
522 SnapshotReader reader(buffer, buffer_len, | 522 SnapshotReader reader(buffer, buffer_len, |
523 Snapshot::kMessage, Isolate::Current()); | 523 Snapshot::kMessage, Isolate::Current()); |
524 String& serialized_str = String::Handle(); | 524 String& serialized_str = String::Handle(); |
525 serialized_str ^= reader.ReadObject(); | 525 serialized_str ^= reader.ReadObject(); |
526 EXPECT(str.Equals(serialized_str)); | 526 EXPECT(str.Equals(serialized_str)); |
(...skipping 21 matching lines...) Expand all Loading... |
548 TestString(data); | 548 TestString(data); |
549 // TODO(sgjesse): Add tests with non-BMP characters. | 549 // TODO(sgjesse): Add tests with non-BMP characters. |
550 } | 550 } |
551 | 551 |
552 | 552 |
553 TEST_CASE(SerializeArray) { | 553 TEST_CASE(SerializeArray) { |
554 StackZone zone(Isolate::Current()); | 554 StackZone zone(Isolate::Current()); |
555 | 555 |
556 // Write snapshot with object content. | 556 // Write snapshot with object content. |
557 uint8_t* buffer; | 557 uint8_t* buffer; |
558 MessageWriter writer(&buffer, &zone_allocator); | 558 MessageWriter writer(&buffer, &zone_allocator, true); |
559 const int kArrayLength = 10; | 559 const int kArrayLength = 10; |
560 Array& array = Array::Handle(Array::New(kArrayLength)); | 560 Array& array = Array::Handle(Array::New(kArrayLength)); |
561 Smi& smi = Smi::Handle(); | 561 Smi& smi = Smi::Handle(); |
562 for (int i = 0; i < kArrayLength; i++) { | 562 for (int i = 0; i < kArrayLength; i++) { |
563 smi ^= Smi::New(i); | 563 smi ^= Smi::New(i); |
564 array.SetAt(i, smi); | 564 array.SetAt(i, smi); |
565 } | 565 } |
566 writer.WriteMessage(array); | 566 writer.WriteMessage(array); |
567 intptr_t buffer_len = writer.BytesWritten(); | 567 intptr_t buffer_len = writer.BytesWritten(); |
568 | 568 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 ExternalTypedData::MaxElements(kExternalTypedDataUint8ArrayCid) + 1; | 638 ExternalTypedData::MaxElements(kExternalTypedDataUint8ArrayCid) + 1; |
639 ExpectEncodeFail(&root); | 639 ExpectEncodeFail(&root); |
640 } | 640 } |
641 | 641 |
642 | 642 |
643 TEST_CASE(SerializeEmptyArray) { | 643 TEST_CASE(SerializeEmptyArray) { |
644 StackZone zone(Isolate::Current()); | 644 StackZone zone(Isolate::Current()); |
645 | 645 |
646 // Write snapshot with object content. | 646 // Write snapshot with object content. |
647 uint8_t* buffer; | 647 uint8_t* buffer; |
648 MessageWriter writer(&buffer, &zone_allocator); | 648 MessageWriter writer(&buffer, &zone_allocator, true); |
649 const int kArrayLength = 0; | 649 const int kArrayLength = 0; |
650 Array& array = Array::Handle(Array::New(kArrayLength)); | 650 Array& array = Array::Handle(Array::New(kArrayLength)); |
651 writer.WriteMessage(array); | 651 writer.WriteMessage(array); |
652 intptr_t buffer_len = writer.BytesWritten(); | 652 intptr_t buffer_len = writer.BytesWritten(); |
653 | 653 |
654 // Read object back from the snapshot. | 654 // Read object back from the snapshot. |
655 SnapshotReader reader(buffer, buffer_len, | 655 SnapshotReader reader(buffer, buffer_len, |
656 Snapshot::kMessage, Isolate::Current()); | 656 Snapshot::kMessage, Isolate::Current()); |
657 Array& serialized_array = Array::Handle(); | 657 Array& serialized_array = Array::Handle(); |
658 serialized_array ^= reader.ReadObject(); | 658 serialized_array ^= reader.ReadObject(); |
659 EXPECT(array.CanonicalizeEquals(serialized_array)); | 659 EXPECT(array.CanonicalizeEquals(serialized_array)); |
660 | 660 |
661 // Read object back from the snapshot into a C structure. | 661 // Read object back from the snapshot into a C structure. |
662 ApiNativeScope scope; | 662 ApiNativeScope scope; |
663 ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator); | 663 ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator); |
664 Dart_CObject* root = api_reader.ReadMessage(); | 664 Dart_CObject* root = api_reader.ReadMessage(); |
665 EXPECT_EQ(Dart_CObject_kArray, root->type); | 665 EXPECT_EQ(Dart_CObject_kArray, root->type); |
666 EXPECT_EQ(kArrayLength, root->value.as_array.length); | 666 EXPECT_EQ(kArrayLength, root->value.as_array.length); |
667 EXPECT(root->value.as_array.values == NULL); | 667 EXPECT(root->value.as_array.values == NULL); |
668 CheckEncodeDecodeMessage(root); | 668 CheckEncodeDecodeMessage(root); |
669 } | 669 } |
670 | 670 |
671 | 671 |
672 TEST_CASE(SerializeByteArray) { | 672 TEST_CASE(SerializeByteArray) { |
673 StackZone zone(Isolate::Current()); | 673 StackZone zone(Isolate::Current()); |
674 | 674 |
675 // Write snapshot with object content. | 675 // Write snapshot with object content. |
676 uint8_t* buffer; | 676 uint8_t* buffer; |
677 MessageWriter writer(&buffer, &zone_allocator); | 677 MessageWriter writer(&buffer, &zone_allocator, true); |
678 const int kTypedDataLength = 256; | 678 const int kTypedDataLength = 256; |
679 TypedData& typed_data = TypedData::Handle( | 679 TypedData& typed_data = TypedData::Handle( |
680 TypedData::New(kTypedDataUint8ArrayCid, kTypedDataLength)); | 680 TypedData::New(kTypedDataUint8ArrayCid, kTypedDataLength)); |
681 for (int i = 0; i < kTypedDataLength; i++) { | 681 for (int i = 0; i < kTypedDataLength; i++) { |
682 typed_data.SetUint8(i, i); | 682 typed_data.SetUint8(i, i); |
683 } | 683 } |
684 writer.WriteMessage(typed_data); | 684 writer.WriteMessage(typed_data); |
685 intptr_t buffer_len = writer.BytesWritten(); | 685 intptr_t buffer_len = writer.BytesWritten(); |
686 | 686 |
687 // Read object back from the snapshot. | 687 // Read object back from the snapshot. |
(...skipping 13 matching lines...) Expand all Loading... |
701 EXPECT(root->value.as_typed_data.values[i] == i); | 701 EXPECT(root->value.as_typed_data.values[i] == i); |
702 } | 702 } |
703 CheckEncodeDecodeMessage(root); | 703 CheckEncodeDecodeMessage(root); |
704 } | 704 } |
705 | 705 |
706 | 706 |
707 #define TEST_TYPED_ARRAY(darttype, ctype) \ | 707 #define TEST_TYPED_ARRAY(darttype, ctype) \ |
708 { \ | 708 { \ |
709 StackZone zone(Isolate::Current()); \ | 709 StackZone zone(Isolate::Current()); \ |
710 uint8_t* buffer; \ | 710 uint8_t* buffer; \ |
711 MessageWriter writer(&buffer, &zone_allocator); \ | 711 MessageWriter writer(&buffer, &zone_allocator, true); \ |
712 const int kArrayLength = 127; \ | 712 const int kArrayLength = 127; \ |
713 TypedData& array = TypedData::Handle( \ | 713 TypedData& array = TypedData::Handle( \ |
714 TypedData::New(kTypedData##darttype##ArrayCid, kArrayLength)); \ | 714 TypedData::New(kTypedData##darttype##ArrayCid, kArrayLength)); \ |
715 intptr_t scale = array.ElementSizeInBytes(); \ | 715 intptr_t scale = array.ElementSizeInBytes(); \ |
716 for (int i = 0; i < kArrayLength; i++) { \ | 716 for (int i = 0; i < kArrayLength; i++) { \ |
717 array.Set##darttype((i * scale), i); \ | 717 array.Set##darttype((i * scale), i); \ |
718 } \ | 718 } \ |
719 writer.WriteMessage(array); \ | 719 writer.WriteMessage(array); \ |
720 intptr_t buffer_len = writer.BytesWritten(); \ | 720 intptr_t buffer_len = writer.BytesWritten(); \ |
721 SnapshotReader reader(buffer, buffer_len, \ | 721 SnapshotReader reader(buffer, buffer_len, \ |
(...skipping 10 matching lines...) Expand all Loading... |
732 #define TEST_EXTERNAL_TYPED_ARRAY(darttype, ctype) \ | 732 #define TEST_EXTERNAL_TYPED_ARRAY(darttype, ctype) \ |
733 { \ | 733 { \ |
734 StackZone zone(Isolate::Current()); \ | 734 StackZone zone(Isolate::Current()); \ |
735 ctype data[] = { 0, 11, 22, 33, 44, 55, 66, 77 }; \ | 735 ctype data[] = { 0, 11, 22, 33, 44, 55, 66, 77 }; \ |
736 intptr_t length = ARRAY_SIZE(data); \ | 736 intptr_t length = ARRAY_SIZE(data); \ |
737 ExternalTypedData& array = ExternalTypedData::Handle( \ | 737 ExternalTypedData& array = ExternalTypedData::Handle( \ |
738 ExternalTypedData::New(kExternalTypedData##darttype##ArrayCid, \ | 738 ExternalTypedData::New(kExternalTypedData##darttype##ArrayCid, \ |
739 reinterpret_cast<uint8_t*>(data), length)); \ | 739 reinterpret_cast<uint8_t*>(data), length)); \ |
740 intptr_t scale = array.ElementSizeInBytes(); \ | 740 intptr_t scale = array.ElementSizeInBytes(); \ |
741 uint8_t* buffer; \ | 741 uint8_t* buffer; \ |
742 MessageWriter writer(&buffer, &zone_allocator); \ | 742 MessageWriter writer(&buffer, &zone_allocator, true); \ |
743 writer.WriteMessage(array); \ | 743 writer.WriteMessage(array); \ |
744 intptr_t buffer_len = writer.BytesWritten(); \ | 744 intptr_t buffer_len = writer.BytesWritten(); \ |
745 SnapshotReader reader(buffer, buffer_len, \ | 745 SnapshotReader reader(buffer, buffer_len, \ |
746 Snapshot::kMessage, Isolate::Current()); \ | 746 Snapshot::kMessage, Isolate::Current()); \ |
747 TypedData& serialized_array = TypedData::Handle(); \ | 747 TypedData& serialized_array = TypedData::Handle(); \ |
748 serialized_array ^= reader.ReadObject(); \ | 748 serialized_array ^= reader.ReadObject(); \ |
749 for (int i = 0; i < length; i++) { \ | 749 for (int i = 0; i < length; i++) { \ |
750 EXPECT_EQ(static_cast<ctype>(data[i]), \ | 750 EXPECT_EQ(static_cast<ctype>(data[i]), \ |
751 serialized_array.Get##darttype(i*scale)); \ | 751 serialized_array.Get##darttype(i*scale)); \ |
752 } \ | 752 } \ |
(...skipping 26 matching lines...) Expand all Loading... |
779 TEST_EXTERNAL_TYPED_ARRAY(Float32, float); | 779 TEST_EXTERNAL_TYPED_ARRAY(Float32, float); |
780 TEST_EXTERNAL_TYPED_ARRAY(Float64, double); | 780 TEST_EXTERNAL_TYPED_ARRAY(Float64, double); |
781 } | 781 } |
782 | 782 |
783 | 783 |
784 TEST_CASE(SerializeEmptyByteArray) { | 784 TEST_CASE(SerializeEmptyByteArray) { |
785 StackZone zone(Isolate::Current()); | 785 StackZone zone(Isolate::Current()); |
786 | 786 |
787 // Write snapshot with object content. | 787 // Write snapshot with object content. |
788 uint8_t* buffer; | 788 uint8_t* buffer; |
789 MessageWriter writer(&buffer, &zone_allocator); | 789 MessageWriter writer(&buffer, &zone_allocator, true); |
790 const int kTypedDataLength = 0; | 790 const int kTypedDataLength = 0; |
791 TypedData& typed_data = TypedData::Handle( | 791 TypedData& typed_data = TypedData::Handle( |
792 TypedData::New(kTypedDataUint8ArrayCid, kTypedDataLength)); | 792 TypedData::New(kTypedDataUint8ArrayCid, kTypedDataLength)); |
793 writer.WriteMessage(typed_data); | 793 writer.WriteMessage(typed_data); |
794 intptr_t buffer_len = writer.BytesWritten(); | 794 intptr_t buffer_len = writer.BytesWritten(); |
795 | 795 |
796 // Read object back from the snapshot. | 796 // Read object back from the snapshot. |
797 SnapshotReader reader(buffer, buffer_len, | 797 SnapshotReader reader(buffer, buffer_len, |
798 Snapshot::kMessage, Isolate::Current()); | 798 Snapshot::kMessage, Isolate::Current()); |
799 TypedData& serialized_typed_data = TypedData::Handle(); | 799 TypedData& serialized_typed_data = TypedData::Handle(); |
800 serialized_typed_data ^= reader.ReadObject(); | 800 serialized_typed_data ^= reader.ReadObject(); |
801 EXPECT(serialized_typed_data.IsTypedData()); | 801 EXPECT(serialized_typed_data.IsTypedData()); |
802 | 802 |
803 // Read object back from the snapshot into a C structure. | 803 // Read object back from the snapshot into a C structure. |
804 ApiNativeScope scope; | 804 ApiNativeScope scope; |
805 ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator); | 805 ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator); |
806 Dart_CObject* root = api_reader.ReadMessage(); | 806 Dart_CObject* root = api_reader.ReadMessage(); |
807 EXPECT_EQ(Dart_CObject_kTypedData, root->type); | 807 EXPECT_EQ(Dart_CObject_kTypedData, root->type); |
808 EXPECT_EQ(Dart_TypedData_kUint8, root->value.as_typed_data.type); | 808 EXPECT_EQ(Dart_TypedData_kUint8, root->value.as_typed_data.type); |
809 EXPECT_EQ(kTypedDataLength, root->value.as_typed_data.length); | 809 EXPECT_EQ(kTypedDataLength, root->value.as_typed_data.length); |
810 EXPECT(root->value.as_typed_data.values == NULL); | 810 EXPECT(root->value.as_typed_data.values == NULL); |
811 CheckEncodeDecodeMessage(root); | 811 CheckEncodeDecodeMessage(root); |
812 } | 812 } |
813 | 813 |
814 | 814 |
815 class TestSnapshotWriter : public SnapshotWriter { | 815 class TestSnapshotWriter : public SnapshotWriter { |
816 public: | 816 public: |
817 static const intptr_t kInitialSize = 64 * KB; | 817 static const intptr_t kInitialSize = 64 * KB; |
818 TestSnapshotWriter(uint8_t** buffer, ReAlloc alloc) | 818 TestSnapshotWriter(uint8_t** buffer, ReAlloc alloc) |
819 : SnapshotWriter(Snapshot::kScript, buffer, alloc, kInitialSize) { | 819 : SnapshotWriter(Snapshot::kScript, buffer, alloc, kInitialSize, true) { |
820 ASSERT(buffer != NULL); | 820 ASSERT(buffer != NULL); |
821 ASSERT(alloc != NULL); | 821 ASSERT(alloc != NULL); |
822 } | 822 } |
823 ~TestSnapshotWriter() { } | 823 ~TestSnapshotWriter() { } |
824 | 824 |
825 // Writes just a script object | 825 // Writes just a script object |
826 void WriteScript(const Script& script) { | 826 void WriteScript(const Script& script) { |
827 WriteObject(script.raw()); | 827 WriteObject(script.raw()); |
828 UnmarkAll(); | 828 UnmarkAll(); |
829 } | 829 } |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1456 // Helper function to call a top level Dart function, serialize the | 1456 // Helper function to call a top level Dart function, serialize the |
1457 // result and deserialize the result into a Dart_CObject structure. | 1457 // result and deserialize the result into a Dart_CObject structure. |
1458 static Dart_CObject* GetDeserializedDartMessage(Dart_Handle lib, | 1458 static Dart_CObject* GetDeserializedDartMessage(Dart_Handle lib, |
1459 const char* dart_function) { | 1459 const char* dart_function) { |
1460 Dart_Handle result; | 1460 Dart_Handle result; |
1461 result = Dart_Invoke(lib, NewString(dart_function), 0, NULL); | 1461 result = Dart_Invoke(lib, NewString(dart_function), 0, NULL); |
1462 EXPECT_VALID(result); | 1462 EXPECT_VALID(result); |
1463 | 1463 |
1464 // Serialize the list into a message. | 1464 // Serialize the list into a message. |
1465 uint8_t* buffer; | 1465 uint8_t* buffer; |
1466 MessageWriter writer(&buffer, &zone_allocator); | 1466 MessageWriter writer(&buffer, &zone_allocator, false); |
1467 const Object& list = Object::Handle(Api::UnwrapHandle(result)); | 1467 const Object& list = Object::Handle(Api::UnwrapHandle(result)); |
1468 writer.WriteMessage(list); | 1468 writer.WriteMessage(list); |
1469 intptr_t buffer_len = writer.BytesWritten(); | 1469 intptr_t buffer_len = writer.BytesWritten(); |
1470 | 1470 |
1471 // Read object back from the snapshot into a C structure. | 1471 // Read object back from the snapshot into a C structure. |
1472 ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator); | 1472 ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator); |
1473 return api_reader.ReadMessage(); | 1473 return api_reader.ReadMessage(); |
1474 } | 1474 } |
1475 | 1475 |
1476 | 1476 |
1477 static void CheckString(Dart_Handle dart_string, const char* expected) { | 1477 static void CheckString(Dart_Handle dart_string, const char* expected) { |
1478 StackZone zone(Isolate::Current()); | 1478 StackZone zone(Isolate::Current()); |
1479 uint8_t* buffer; | 1479 uint8_t* buffer; |
1480 MessageWriter writer(&buffer, &zone_allocator); | 1480 MessageWriter writer(&buffer, &zone_allocator, false); |
1481 String& str = String::Handle(); | 1481 String& str = String::Handle(); |
1482 str ^= Api::UnwrapHandle(dart_string); | 1482 str ^= Api::UnwrapHandle(dart_string); |
1483 writer.WriteMessage(str); | 1483 writer.WriteMessage(str); |
1484 intptr_t buffer_len = writer.BytesWritten(); | 1484 intptr_t buffer_len = writer.BytesWritten(); |
1485 | 1485 |
1486 // Read object back from the snapshot into a C structure. | 1486 // Read object back from the snapshot into a C structure. |
1487 ApiNativeScope scope; | 1487 ApiNativeScope scope; |
1488 ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator); | 1488 ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator); |
1489 Dart_CObject* root = api_reader.ReadMessage(); | 1489 Dart_CObject* root = api_reader.ReadMessage(); |
1490 EXPECT_NOTNULL(root); | 1490 EXPECT_NOTNULL(root); |
1491 EXPECT_EQ(Dart_CObject_kString, root->type); | 1491 EXPECT_EQ(Dart_CObject_kString, root->type); |
1492 EXPECT_STREQ(expected, root->value.as_string); | 1492 EXPECT_STREQ(expected, root->value.as_string); |
1493 CheckEncodeDecodeMessage(root); | 1493 CheckEncodeDecodeMessage(root); |
1494 } | 1494 } |
1495 | 1495 |
1496 | 1496 |
1497 static void CheckStringInvalid(Dart_Handle dart_string) { | 1497 static void CheckStringInvalid(Dart_Handle dart_string) { |
1498 StackZone zone(Isolate::Current()); | 1498 StackZone zone(Isolate::Current()); |
1499 uint8_t* buffer; | 1499 uint8_t* buffer; |
1500 MessageWriter writer(&buffer, &zone_allocator); | 1500 MessageWriter writer(&buffer, &zone_allocator, false); |
1501 String& str = String::Handle(); | 1501 String& str = String::Handle(); |
1502 str ^= Api::UnwrapHandle(dart_string); | 1502 str ^= Api::UnwrapHandle(dart_string); |
1503 writer.WriteMessage(str); | 1503 writer.WriteMessage(str); |
1504 intptr_t buffer_len = writer.BytesWritten(); | 1504 intptr_t buffer_len = writer.BytesWritten(); |
1505 | 1505 |
1506 // Read object back from the snapshot into a C structure. | 1506 // Read object back from the snapshot into a C structure. |
1507 ApiNativeScope scope; | 1507 ApiNativeScope scope; |
1508 ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator); | 1508 ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator); |
1509 Dart_CObject* root = api_reader.ReadMessage(); | 1509 Dart_CObject* root = api_reader.ReadMessage(); |
1510 EXPECT_NOTNULL(root); | 1510 EXPECT_NOTNULL(root); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1600 Dart_Invoke(lib, NewString("getCrappyString"), 0, NULL); | 1600 Dart_Invoke(lib, NewString("getCrappyString"), 0, NULL); |
1601 EXPECT_VALID(crappy_string_result); | 1601 EXPECT_VALID(crappy_string_result); |
1602 EXPECT(Dart_IsString(crappy_string_result)); | 1602 EXPECT(Dart_IsString(crappy_string_result)); |
1603 | 1603 |
1604 { | 1604 { |
1605 DARTSCOPE(isolate); | 1605 DARTSCOPE(isolate); |
1606 | 1606 |
1607 { | 1607 { |
1608 StackZone zone(Isolate::Current()); | 1608 StackZone zone(Isolate::Current()); |
1609 uint8_t* buffer; | 1609 uint8_t* buffer; |
1610 MessageWriter writer(&buffer, &zone_allocator); | 1610 MessageWriter writer(&buffer, &zone_allocator, false); |
1611 Smi& smi = Smi::Handle(); | 1611 Smi& smi = Smi::Handle(); |
1612 smi ^= Api::UnwrapHandle(smi_result); | 1612 smi ^= Api::UnwrapHandle(smi_result); |
1613 writer.WriteMessage(smi); | 1613 writer.WriteMessage(smi); |
1614 intptr_t buffer_len = writer.BytesWritten(); | 1614 intptr_t buffer_len = writer.BytesWritten(); |
1615 | 1615 |
1616 // Read object back from the snapshot into a C structure. | 1616 // Read object back from the snapshot into a C structure. |
1617 ApiNativeScope scope; | 1617 ApiNativeScope scope; |
1618 ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator); | 1618 ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator); |
1619 Dart_CObject* root = api_reader.ReadMessage(); | 1619 Dart_CObject* root = api_reader.ReadMessage(); |
1620 EXPECT_NOTNULL(root); | 1620 EXPECT_NOTNULL(root); |
1621 EXPECT_EQ(Dart_CObject_kInt32, root->type); | 1621 EXPECT_EQ(Dart_CObject_kInt32, root->type); |
1622 EXPECT_EQ(42, root->value.as_int32); | 1622 EXPECT_EQ(42, root->value.as_int32); |
1623 CheckEncodeDecodeMessage(root); | 1623 CheckEncodeDecodeMessage(root); |
1624 } | 1624 } |
1625 { | 1625 { |
1626 StackZone zone(Isolate::Current()); | 1626 StackZone zone(Isolate::Current()); |
1627 uint8_t* buffer; | 1627 uint8_t* buffer; |
1628 MessageWriter writer(&buffer, &zone_allocator); | 1628 MessageWriter writer(&buffer, &zone_allocator, false); |
1629 Bigint& bigint = Bigint::Handle(); | 1629 Bigint& bigint = Bigint::Handle(); |
1630 bigint ^= Api::UnwrapHandle(bigint_result); | 1630 bigint ^= Api::UnwrapHandle(bigint_result); |
1631 writer.WriteMessage(bigint); | 1631 writer.WriteMessage(bigint); |
1632 intptr_t buffer_len = writer.BytesWritten(); | 1632 intptr_t buffer_len = writer.BytesWritten(); |
1633 | 1633 |
1634 // Read object back from the snapshot into a C structure. | 1634 // Read object back from the snapshot into a C structure. |
1635 ApiNativeScope scope; | 1635 ApiNativeScope scope; |
1636 ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator); | 1636 ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator); |
1637 Dart_CObject* root = api_reader.ReadMessage(); | 1637 Dart_CObject* root = api_reader.ReadMessage(); |
1638 EXPECT_NOTNULL(root); | 1638 EXPECT_NOTNULL(root); |
(...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2718 EXPECT_SUBSTRING("Exception: nulltruefalse123456æøå3.14[]100123456789\n", | 2718 EXPECT_SUBSTRING("Exception: nulltruefalse123456æøå3.14[]100123456789\n", |
2719 Dart_GetError(result)); | 2719 Dart_GetError(result)); |
2720 | 2720 |
2721 Dart_ExitScope(); | 2721 Dart_ExitScope(); |
2722 } | 2722 } |
2723 | 2723 |
2724 | 2724 |
2725 TEST_CASE(OmittedObjectEncodingLength) { | 2725 TEST_CASE(OmittedObjectEncodingLength) { |
2726 StackZone zone(Isolate::Current()); | 2726 StackZone zone(Isolate::Current()); |
2727 uint8_t* buffer; | 2727 uint8_t* buffer; |
2728 MessageWriter writer(&buffer, &zone_allocator); | 2728 MessageWriter writer(&buffer, &zone_allocator, true); |
2729 writer.WriteInlinedObjectHeader(kOmittedObjectId); | 2729 writer.WriteInlinedObjectHeader(kOmittedObjectId); |
2730 // For performance, we'd like single-byte headers when ids are omitted. | 2730 // For performance, we'd like single-byte headers when ids are omitted. |
2731 // If this starts failing, consider renumbering the snapshot ids. | 2731 // If this starts failing, consider renumbering the snapshot ids. |
2732 EXPECT_EQ(1, writer.BytesWritten()); | 2732 EXPECT_EQ(1, writer.BytesWritten()); |
2733 } | 2733 } |
2734 | 2734 |
2735 } // namespace dart | 2735 } // namespace dart |
OLD | NEW |