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

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

Issue 22303002: Auto create ApiLocalScope before calling native functions, this ensures that (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intermediate_language_x64.cc ('k') | runtime/vm/native_entry.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) 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_NATIVE_ARGUMENTS_H_ 5 #ifndef VM_NATIVE_ARGUMENTS_H_
6 #define VM_NATIVE_ARGUMENTS_H_ 6 #define VM_NATIVE_ARGUMENTS_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/globals.h" 9 #include "vm/globals.h"
10 #include "vm/simulator.h" 10 #include "vm/simulator.h"
11 #include "vm/stub_code.h" 11 #include "vm/stub_code.h"
12 12
13 namespace dart { 13 namespace dart {
14 14
15 DECLARE_FLAG(bool, deoptimize_alot);
16 DECLARE_FLAG(bool, trace_natives);
17 DECLARE_FLAG(bool, verify_on_transition);
18
15 // Forward declarations. 19 // Forward declarations.
16 class BootstrapNatives; 20 class BootstrapNatives;
17 class Isolate; 21 class Isolate;
18 class Object; 22 class Object;
19 class RawObject; 23 class RawObject;
20 class Simulator; 24 class Simulator;
21 25
22
23 #if defined(TESTING) || defined(DEBUG) 26 #if defined(TESTING) || defined(DEBUG)
24 27
25 #if defined(USING_SIMULATOR) 28 #if defined(USING_SIMULATOR)
26 #define CHECK_STACK_ALIGNMENT { \ 29 #define CHECK_STACK_ALIGNMENT { \
27 uword current_sp = Simulator::Current()->get_register(SPREG); \ 30 uword current_sp = Simulator::Current()->get_register(SPREG); \
28 ASSERT((OS::ActivationFrameAlignment() == 0) || \ 31 ASSERT((OS::ActivationFrameAlignment() == 0) || \
29 (Utils::IsAligned(current_sp, OS::ActivationFrameAlignment()))); \ 32 (Utils::IsAligned(current_sp, OS::ActivationFrameAlignment()))); \
30 } 33 }
31 #elif defined(TARGET_OS_WINDOWS) 34 #elif defined(TARGET_OS_WINDOWS)
32 // The compiler may dynamically align the stack on Windows, so do not check. 35 // The compiler may dynamically align the stack on Windows, so do not check.
33 #define CHECK_STACK_ALIGNMENT { } 36 #define CHECK_STACK_ALIGNMENT { }
34 #else 37 #else
35 #define CHECK_STACK_ALIGNMENT { \ 38 #define CHECK_STACK_ALIGNMENT { \
36 uword (*func)() = \ 39 uword (*func)() = \
37 reinterpret_cast<uword (*)()>(StubCode::GetStackPointerEntryPoint()); \ 40 reinterpret_cast<uword (*)()>(StubCode::GetStackPointerEntryPoint()); \
38 uword current_sp = func(); \ 41 uword current_sp = func(); \
39 ASSERT((OS::ActivationFrameAlignment() == 0) || \ 42 ASSERT((OS::ActivationFrameAlignment() == 0) || \
40 (Utils::IsAligned(current_sp, OS::ActivationFrameAlignment()))); \ 43 (Utils::IsAligned(current_sp, OS::ActivationFrameAlignment()))); \
41 } 44 }
42 #endif 45 #endif
43 46
47 #define VERIFY_ON_TRANSITION \
48 if (FLAG_verify_on_transition) { \
49 VerifyPointersVisitor::VerifyPointers(); \
50 Isolate::Current()->heap()->Verify(); \
51 }
52 #define TRACE_NATIVES(name) \
53 if (FLAG_trace_natives) { \
54 OS::Print("Calling native: %s\n", name); \
55 }
56 #define DEOPTIMIZE_ALOT \
57 if (FLAG_deoptimize_alot) { \
58 DeoptimizeAll(); \
59 }
60
44 #else 61 #else
45 62
46 #define CHECK_STACK_ALIGNMENT { } 63 #define CHECK_STACK_ALIGNMENT { }
64 #define VERIFY_ON_TRANSITION { }
65 #define TRACE_NATIVES(name) { }
66 #define DEOPTIMIZE_ALOT { }
47 67
48 #endif 68 #endif
49 69
50 70
51 // Class NativeArguments is used to access arguments passed in from 71 // Class NativeArguments is used to access arguments passed in from
52 // generated dart code to a runtime function or a dart library native 72 // generated dart code to a runtime function or a dart library native
53 // function. It is also used to set the return value if any at the slot 73 // function. It is also used to set the return value if any at the slot
54 // reserved for return values. 74 // reserved for return values.
55 // All runtime function/dart library native functions have the 75 // All runtime function/dart library native functions have the
56 // following signature: 76 // following signature:
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 188
169 Isolate* isolate_; // Current isolate pointer. 189 Isolate* isolate_; // Current isolate pointer.
170 int argc_tag_; // Encodes argument count and invoked native call type. 190 int argc_tag_; // Encodes argument count and invoked native call type.
171 RawObject*(*argv_)[]; // Pointer to an array of arguments to runtime call. 191 RawObject*(*argv_)[]; // Pointer to an array of arguments to runtime call.
172 RawObject** retval_; // Pointer to the return value area. 192 RawObject** retval_; // Pointer to the return value area.
173 }; 193 };
174 194
175 } // namespace dart 195 } // namespace dart
176 196
177 #endif // VM_NATIVE_ARGUMENTS_H_ 197 #endif // VM_NATIVE_ARGUMENTS_H_
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_x64.cc ('k') | runtime/vm/native_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698