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

Unified Diff: runtime/vm/dart_api_message.h

Issue 1319583003: Use the zone in ApiNativeScope for allocating objects in the ApiMessageReader instead of passing in… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address-code-review-comments Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/dart_api_message.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_message.h
diff --git a/runtime/vm/dart_api_message.h b/runtime/vm/dart_api_message.h
index 70d55f9eb75d39a7a58816fde1c4d417f4564125..16a138bc44b80786a6bc730a9091adfab0a6faff 100644
--- a/runtime/vm/dart_api_message.h
+++ b/runtime/vm/dart_api_message.h
@@ -41,14 +41,10 @@ struct Dart_CObject_Internal : public Dart_CObject {
// Reads a message snapshot into a C structure.
class ApiMessageReader : public BaseReader {
public:
- // The allocator passed is used to allocate memory for the C structure used
- // to represent the message snapshot. This allocator must keep track of the
- // memory allocated as there is no way to run through the resulting C
- // structure and free the individual pieces. Using a zone based allocator is
- // recommended.
- ApiMessageReader(const uint8_t* buffer,
- intptr_t length,
- ReAlloc alloc);
+ // The ApiMessageReader object must be enclosed by an ApiNativeScope.
+ // Allocation of all C Heap objects is done in the zone associated with
+ // the enclosing ApiNativeScope.
+ ApiMessageReader(const uint8_t* buffer, intptr_t length);
~ApiMessageReader() { }
Dart_CObject* ReadMessage();
@@ -139,10 +135,11 @@ class ApiMessageReader : public BaseReader {
Dart_CObject* GetCanonicalMintObject(Dart_CObject_Type type,
int64_t value64);
- // Allocation of the structures for the decoded message happens
- // either in the supplied zone or using the supplied allocation
- // function.
- ReAlloc alloc_;
+ uint8_t* allocator(intptr_t size) {
+ return zone_->Realloc<uint8_t>(NULL, 0, size);
+ }
+
+ Zone* zone_; // Zone in which C heap objects are allocated.
ApiGrowableArray<BackRefNode*> backward_references_;
ApiGrowableArray<Dart_CObject*> vm_isolate_references_;
Dart_CObject** vm_symbol_references_;
« no previous file with comments | « no previous file | runtime/vm/dart_api_message.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698