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

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

Issue 11441021: Pass handles not raw objects into methods. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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) 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_DART_ENTRY_H_ 5 #ifndef VM_DART_ENTRY_H_
6 #define VM_DART_ENTRY_H_ 6 #define VM_DART_ENTRY_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/growable_array.h" 9 #include "vm/growable_array.h"
10 10
11 namespace dart { 11 namespace dart {
12 12
13 // Forward declarations. 13 // Forward declarations.
14 class Array; 14 class Array;
15 class Closure; 15 class Closure;
16 class Context; 16 class Context;
17 class Function; 17 class Function;
18 class Instance; 18 class Instance;
19 class Integer; 19 class Integer;
20 class Library; 20 class Library;
21 class Object; 21 class Object;
22 class RawArray; 22 class RawArray;
23 class RawInstance; 23 class RawInstance;
24 class RawObject; 24 class RawObject;
25 class RawString;
25 class String; 26 class String;
26 27
27 // An arguments descriptor array consists of the total argument count; the 28 // An arguments descriptor array consists of the total argument count; the
28 // positional argument count; a sequence of (name, position) pairs, sorted 29 // positional argument count; a sequence of (name, position) pairs, sorted
29 // by name, for each named optional argument; and a terminating null to 30 // by name, for each named optional argument; and a terminating null to
30 // simplify iterating in generated code. 31 // simplify iterating in generated code.
31 class ArgumentsDescriptor : public ValueObject { 32 class ArgumentsDescriptor : public ValueObject {
32 public: 33 public:
33 explicit ArgumentsDescriptor(RawObject* array); 34 explicit ArgumentsDescriptor(const Array& array);
34 35
35 // Accessors. 36 // Accessors.
36 intptr_t Count() const; 37 intptr_t Count() const;
37 intptr_t PositionalCount() const; 38 intptr_t PositionalCount() const;
38 intptr_t NamedCount() const { return Count() - PositionalCount(); } 39 intptr_t NamedCount() const { return Count() - PositionalCount(); }
39 RawObject* NameAt(intptr_t index) const; 40 RawString* NameAt(intptr_t index) const;
40 41
41 // Generated code support. 42 // Generated code support.
42 static intptr_t count_offset(); 43 static intptr_t count_offset();
43 static intptr_t positional_count_offset(); 44 static intptr_t positional_count_offset();
44 static intptr_t first_named_entry_offset(); 45 static intptr_t first_named_entry_offset();
45 static intptr_t name_offset() { return kNameOffset * kWordSize; } 46 static intptr_t name_offset() { return kNameOffset * kWordSize; }
46 static intptr_t position_offset() { return kPositionOffset * kWordSize; } 47 static intptr_t position_offset() { return kPositionOffset * kWordSize; }
47 static intptr_t named_entry_size() { return kNamedEntrySize * kWordSize; } 48 static intptr_t named_entry_size() { return kNamedEntrySize * kWordSize; }
48 49
49 // Allocate and return an arguments descriptor. The first 50 // Allocate and return an arguments descriptor. The first
(...skipping 16 matching lines...) Expand all
66 kPositionOffset, 67 kPositionOffset,
67 kNamedEntrySize, 68 kNamedEntrySize,
68 }; 69 };
69 70
70 static intptr_t LengthFor(intptr_t count) { 71 static intptr_t LengthFor(intptr_t count) {
71 // Add 1 for the terminating null. 72 // Add 1 for the terminating null.
72 return kFirstNamedEntryIndex + (kNamedEntrySize * count) + 1; 73 return kFirstNamedEntryIndex + (kNamedEntrySize * count) + 1;
73 } 74 }
74 75
75 const Array& array_; 76 const Array& array_;
77
78 DISALLOW_COPY_AND_ASSIGN(ArgumentsDescriptor);
76 }; 79 };
77 80
78 81
79 // DartEntry abstracts functionality needed to resolve dart functions 82 // DartEntry abstracts functionality needed to resolve dart functions
80 // and invoke them from C++. 83 // and invoke them from C++.
81 class DartEntry : public AllStatic { 84 class DartEntry : public AllStatic {
82 public: 85 public:
83 // On success, returns a RawInstance. On failure, a RawError. 86 // On success, returns a RawInstance. On failure, a RawError.
84 typedef RawObject* (*invokestub)(uword entry_point, 87 typedef RawObject* (*invokestub)(uword entry_point,
85 const Array& arguments_descriptor, 88 const Array& arguments_descriptor,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 146
144 // Gets the _id field of a SendPort/ReceivePort. 147 // Gets the _id field of a SendPort/ReceivePort.
145 // 148 //
146 // Returns the value of _id on success, a RawError on failure. 149 // Returns the value of _id on success, a RawError on failure.
147 static RawObject* PortGetId(const Instance& port); 150 static RawObject* PortGetId(const Instance& port);
148 }; 151 };
149 152
150 } // namespace dart 153 } // namespace dart
151 154
152 #endif // VM_DART_ENTRY_H_ 155 #endif // VM_DART_ENTRY_H_
OLDNEW
« no previous file with comments | « runtime/vm/code_generator.cc ('k') | runtime/vm/dart_entry.cc » ('j') | runtime/vm/dart_entry.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698