Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Side by Side Diff: runtime/vm/snapshot.h

Issue 9325022: Decode the Dart message into a Dart_CMessage structure before calling the native port callback (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #ifndef VM_SNAPSHOT_H_ 5 #ifndef VM_SNAPSHOT_H_
6 #define VM_SNAPSHOT_H_ 6 #define VM_SNAPSHOT_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/allocation.h" 9 #include "vm/allocation.h"
10 #include "vm/bitfield.h" 10 #include "vm/bitfield.h"
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 enum Type { 414 enum Type {
415 kTypeArguments = Dart_CObject::kNumberOfTypes, 415 kTypeArguments = Dart_CObject::kNumberOfTypes,
416 kDynamicType, 416 kDynamicType,
417 }; 417 };
418 }; 418 };
419 419
420 420
421 // Reads a message snapshot into C structure. 421 // Reads a message snapshot into C structure.
422 class CMessageReader : public BaseReader { 422 class CMessageReader : public BaseReader {
423 public: 423 public:
424 // Creates a message reader where the allocated Dart_CMessage
425 // structure and all the allocated Dart_CObject structures are
426 // allocated using the supplied allocation function.
424 CMessageReader(const uint8_t* buffer, intptr_t length, ReAlloc alloc); 427 CMessageReader(const uint8_t* buffer, intptr_t length, ReAlloc alloc);
428 // Creates a message reader where the allocated Dart_CMessage
429 // structure and all the allocated Dart_CObject structures are
430 // allocated in the supplied zone. The supplied zone will also be
431 // used for temporary allocations for message decoding.
432 CMessageReader(const uint8_t* buffer, intptr_t length, Zone* zone);
siva 2012/02/04 01:55:43 Ditto comment regarding this version of the constr
Søren Gjesse 2012/02/06 16:25:52 See comment in native_message_handler.cc
425 ~CMessageReader() { } 433 ~CMessageReader() { }
426 434
427 Dart_CMessage* ReadMessage(); 435 Dart_CMessage* ReadMessage();
428 436
429 private: 437 private:
430 // Allocates a Dart_CObject object on the C heap. 438 // Allocate a piece of memory for the decoded message data.
439 uint8_t* Allocate(uint8_t* ptr, intptr_t old_size, intptr_t new_size);
440 // Allocates a Dart_CObject object.
431 Dart_CObject* AllocateDartCObject(); 441 Dart_CObject* AllocateDartCObject();
432 // Allocates a Dart_CObject object with the specified type on the C heap. 442 // Allocates a Dart_CObject object with the specified type.
433 Dart_CObject* AllocateDartCObject(Dart_CObject::Type type); 443 Dart_CObject* AllocateDartCObject(Dart_CObject::Type type);
434 // Allocates a Dart_CObject object for the null object on the C heap. 444 // Allocates a Dart_CObject object for the null object.
435 Dart_CObject* AllocateDartCObjectNull(); 445 Dart_CObject* AllocateDartCObjectNull();
436 // Allocates a Dart_CObject object for a boolean object on the C heap. 446 // Allocates a Dart_CObject object for a boolean object.
437 Dart_CObject* AllocateDartCObjectBool(bool value); 447 Dart_CObject* AllocateDartCObjectBool(bool value);
438 // Allocates a Dart_CObject object for for a 32-bit integer on the C heap. 448 // Allocates a Dart_CObject object for for a 32-bit integer.
439 Dart_CObject* AllocateDartCObjectInt32(int32_t value); 449 Dart_CObject* AllocateDartCObjectInt32(int32_t value);
440 // Allocates a Dart_CObject object for a double on the C heap. 450 // Allocates a Dart_CObject object for a double.
441 Dart_CObject* AllocateDartCObjectDouble(double value); 451 Dart_CObject* AllocateDartCObjectDouble(double value);
442 // Allocates a Dart_CObject object for string data on the C heap. 452 // Allocates a Dart_CObject object for string data.
443 Dart_CObject* AllocateDartCObjectString(intptr_t length); 453 Dart_CObject* AllocateDartCObjectString(intptr_t length);
444 // Allocates a C array of Dart_CObject objects on the C heap. 454 // Allocates a C array of Dart_CObject objects.
445 Dart_CObject* AllocateDartCObjectArray(intptr_t length); 455 Dart_CObject* AllocateDartCObjectArray(intptr_t length);
446 456
457 void Init();
458
447 intptr_t LookupInternalClass(intptr_t class_header); 459 intptr_t LookupInternalClass(intptr_t class_header);
448 Dart_CObject* ReadInlinedObject(intptr_t object_id); 460 Dart_CObject* ReadInlinedObject(intptr_t object_id);
449 Dart_CObject* ReadObjectImpl(intptr_t header); 461 Dart_CObject* ReadObjectImpl(intptr_t header);
450 Dart_CObject* ReadIndexedObject(intptr_t object_id); 462 Dart_CObject* ReadIndexedObject(intptr_t object_id);
451 Dart_CObject* ReadObject(); 463 Dart_CObject* ReadObject();
452 464
453 // Add object to backward references. 465 // Add object to backward references.
454 void AddBackwardReference(intptr_t id, Dart_CObject* obj); 466 void AddBackwardReference(intptr_t id, Dart_CObject* obj);
455 467
456 Dart_CObject_Internal* AsInternal(Dart_CObject* object) { 468 Dart_CObject_Internal* AsInternal(Dart_CObject* object) {
457 ASSERT(object->type >= Dart_CObject::kNumberOfTypes); 469 ASSERT(object->type >= Dart_CObject::kNumberOfTypes);
458 return reinterpret_cast<Dart_CObject_Internal*>(object); 470 return reinterpret_cast<Dart_CObject_Internal*>(object);
459 } 471 }
460 472
473 // Allocation of the structures for the decoded message happens
474 // either in the supplied zone or using the supplied allocation
475 // function.
476 Zone* zone_;
siva 2012/02/04 01:55:43 Ditto comment.
461 ReAlloc alloc_; 477 ReAlloc alloc_;
462 GrowableArray<Dart_CObject*> backward_references_; 478 GrowableArray<Dart_CObject*> backward_references_;
463 479
464 Dart_CObject type_arguments_marker; 480 Dart_CObject type_arguments_marker;
465 Dart_CObject dynamic_type_marker; 481 Dart_CObject dynamic_type_marker;
466 }; 482 };
467 483
468 484
469 class BaseWriter { 485 class BaseWriter {
470 public: 486 public:
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 650
635 private: 651 private:
636 SnapshotWriter* writer_; 652 SnapshotWriter* writer_;
637 653
638 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); 654 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor);
639 }; 655 };
640 656
641 } // namespace dart 657 } // namespace dart
642 658
643 #endif // VM_SNAPSHOT_H_ 659 #endif // VM_SNAPSHOT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698