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

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

Issue 12744006: Added check that the object being stored as a return value in the NativeArguments array is a Dart i… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/raw_object.h » ('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_NATIVE_ENTRY_H_ 5 #ifndef VM_NATIVE_ENTRY_H_
6 #define VM_NATIVE_ENTRY_H_ 6 #define VM_NATIVE_ENTRY_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/code_generator.h" 10 #include "vm/code_generator.h"
(...skipping 10 matching lines...) Expand all
21 21
22 // Forward declarations. 22 // Forward declarations.
23 class Class; 23 class Class;
24 class String; 24 class String;
25 25
26 typedef void (*NativeFunction)(NativeArguments* arguments); 26 typedef void (*NativeFunction)(NativeArguments* arguments);
27 27
28 28
29 #define NATIVE_ENTRY_FUNCTION(name) BootstrapNatives::DN_##name 29 #define NATIVE_ENTRY_FUNCTION(name) BootstrapNatives::DN_##name
30 30
31 #ifdef DEBUG
32 #define SET_NATIVE_RETVAL(args, value) \
33 RawObject* retval = value; \
34 ASSERT(retval->IsDartInstance()); \
35 arguments->SetReturnUnsafe(retval);
36 #else
37 #define SET_NATIVE_RETVAL(arguments, value) \
38 arguments->SetReturnUnsafe(value);
39 #endif
31 40
32 #define DEFINE_NATIVE_ENTRY(name, argument_count) \ 41 #define DEFINE_NATIVE_ENTRY(name, argument_count) \
33 static RawObject* DN_Helper##name(Isolate* isolate, \ 42 static RawObject* DN_Helper##name(Isolate* isolate, \
34 NativeArguments* arguments); \ 43 NativeArguments* arguments); \
35 void NATIVE_ENTRY_FUNCTION(name)(Dart_NativeArguments args) { \ 44 void NATIVE_ENTRY_FUNCTION(name)(Dart_NativeArguments args) { \
36 CHECK_STACK_ALIGNMENT; \ 45 CHECK_STACK_ALIGNMENT; \
37 VERIFY_ON_TRANSITION; \ 46 VERIFY_ON_TRANSITION; \
38 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); \ 47 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); \
39 ASSERT(arguments->NativeArgCount() == argument_count); \ 48 ASSERT(arguments->NativeArgCount() == argument_count); \
40 if (FLAG_trace_natives) OS::Print("Calling native: %s\n", ""#name); \ 49 if (FLAG_trace_natives) OS::Print("Calling native: %s\n", ""#name); \
41 { \ 50 { \
42 StackZone zone(arguments->isolate()); \ 51 StackZone zone(arguments->isolate()); \
43 HANDLESCOPE(arguments->isolate()); \ 52 HANDLESCOPE(arguments->isolate()); \
44 arguments->SetReturnUnsafe( \ 53 SET_NATIVE_RETVAL(arguments, \
45 DN_Helper##name(arguments->isolate(), arguments)); \ 54 DN_Helper##name(arguments->isolate(), arguments)); \
46 if (FLAG_deoptimize_alot) DeoptimizeAll(); \ 55 if (FLAG_deoptimize_alot) DeoptimizeAll(); \
47 } \ 56 } \
48 VERIFY_ON_TRANSITION; \ 57 VERIFY_ON_TRANSITION; \
49 } \ 58 } \
50 static RawObject* DN_Helper##name(Isolate* isolate, \ 59 static RawObject* DN_Helper##name(Isolate* isolate, \
51 NativeArguments* arguments) 60 NativeArguments* arguments)
52 61
53 62
54 // Natives should throw an exception if an illegal argument or null is passed. 63 // Natives should throw an exception if an illegal argument or null is passed.
55 // type name = value. 64 // type name = value.
(...skipping 29 matching lines...) Expand all
85 public: 94 public:
86 // Resolve specified dart native function to the actual native entrypoint. 95 // Resolve specified dart native function to the actual native entrypoint.
87 static NativeFunction ResolveNative(const Class& cls, 96 static NativeFunction ResolveNative(const Class& cls,
88 const String& function_name, 97 const String& function_name,
89 int number_of_arguments); 98 int number_of_arguments);
90 }; 99 };
91 100
92 } // namespace dart 101 } // namespace dart
93 102
94 #endif // VM_NATIVE_ENTRY_H_ 103 #endif // VM_NATIVE_ENTRY_H_
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698