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

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

Issue 8523013: Cache isolate in the StackTrace object to that we don't call (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 years, 1 month 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
« no previous file with comments | « no previous file | runtime/vm/allocation.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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_ALLOCATION_H_ 5 #ifndef VM_ALLOCATION_H_
6 #define VM_ALLOCATION_H_ 6 #define VM_ALLOCATION_H_
7 7
8 #include "vm/assert.h" 8 #include "vm/assert.h"
9 9
10 namespace dart { 10 namespace dart {
11 11
12 // Forward declarations.
13 class Isolate;
14
12 // Stack allocated objects subclass from this base class. Objects of this type 15 // Stack allocated objects subclass from this base class. Objects of this type
13 // cannot be allocated on either the C or object heaps. Destructors for objects 16 // cannot be allocated on either the C or object heaps. Destructors for objects
14 // of this type will not be run unless the stack is unwound through normal 17 // of this type will not be run unless the stack is unwound through normal
15 // program control flow. 18 // program control flow.
16 class ValueObject { 19 class ValueObject {
17 public: 20 public:
18 ValueObject() { } 21 ValueObject() { }
19 ~ValueObject() { } 22 ~ValueObject() { }
20 23
21 private: 24 private:
22 DISALLOW_ALLOCATION(); 25 DISALLOW_ALLOCATION();
23 // TODO(5411081): Add DISALLOW_COPY_AND_ASSIGN(ValueObject) once the mac 26 // TODO(5411081): Add DISALLOW_COPY_AND_ASSIGN(ValueObject) once the mac
24 // build issue is resolved. 27 // build issue is resolved.
25 }; 28 };
26 29
27 30
28 // Stack resources subclass from this base class. The VM will ensure that the 31 // Stack resources subclass from this base class. The VM will ensure that the
29 // destructors of these objects are called before the stack is unwound past the 32 // destructors of these objects are called before the stack is unwound past the
30 // objects location on the stack. Use stack resource objects if objects 33 // objects location on the stack. Use stack resource objects if objects
31 // need to be destroyed even in the case of exceptions when a Longjump is done 34 // need to be destroyed even in the case of exceptions when a Longjump is done
32 // to a stack frame above the frame where these objects were allocated. 35 // to a stack frame above the frame where these objects were allocated.
33 class StackResource { 36 class StackResource {
34 public: 37 public:
35 StackResource(); 38 StackResource();
36 virtual ~StackResource(); 39 virtual ~StackResource();
37 40
41 Isolate* isolate() const { return isolate_; }
42
38 // The delete operator should be private instead of public, but unfortunately 43 // The delete operator should be private instead of public, but unfortunately
39 // the compiler complains when compiling the destructors for subclasses. 44 // the compiler complains when compiling the destructors for subclasses.
40 void operator delete(void* pointer) { UNREACHABLE(); } 45 void operator delete(void* pointer) { UNREACHABLE(); }
41 46
42 private: 47 private:
48 Isolate* isolate_; // Current isolate for this stack resource.
43 StackResource* previous_; 49 StackResource* previous_;
44 50
45 void* operator new(uword size); 51 void* operator new(uword size);
46 52
47 DISALLOW_COPY_AND_ASSIGN(StackResource); 53 DISALLOW_COPY_AND_ASSIGN(StackResource);
48 }; 54 };
49 55
50 56
51 // Static allocated classes only contain static members and can never 57 // Static allocated classes only contain static members and can never
52 // be instantiated in the heap or on the stack. 58 // be instantiated in the heap or on the stack.
(...skipping 27 matching lines...) Expand all
80 // deallocated by invoking DeleteAll() on the zone they live in. 86 // deallocated by invoking DeleteAll() on the zone they live in.
81 void operator delete(void* pointer) { UNREACHABLE(); } 87 void operator delete(void* pointer) { UNREACHABLE(); }
82 88
83 private: 89 private:
84 DISALLOW_COPY_AND_ASSIGN(ZoneAllocated); 90 DISALLOW_COPY_AND_ASSIGN(ZoneAllocated);
85 }; 91 };
86 92
87 } // namespace dart 93 } // namespace dart
88 94
89 #endif // VM_ALLOCATION_H_ 95 #endif // VM_ALLOCATION_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/allocation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698