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

Unified Diff: runtime/vm/stub_code_arm.cc

Issue 200693002: Set VMTag from stubs when transitioning between Dart and Native (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/stub_code.h ('k') | runtime/vm/stub_code_ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/stub_code_arm.cc
diff --git a/runtime/vm/stub_code_arm.cc b/runtime/vm/stub_code_arm.cc
index df5e190a274dfc2d77d9504c1b5f0859651851b9..6b40a5c29e10a30701038aa264b49e7e76c18bd8 100644
--- a/runtime/vm/stub_code_arm.cc
+++ b/runtime/vm/stub_code_arm.cc
@@ -15,6 +15,7 @@
#include "vm/object_store.h"
#include "vm/stack_frame.h"
#include "vm/stub_code.h"
+#include "vm/tags.h"
#define __ assembler->
@@ -57,6 +58,21 @@ void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) {
// Cache Isolate pointer into CTX while executing runtime code.
__ mov(CTX, ShifterOperand(R0));
+#if defined(DEBUG)
+ { Label ok;
+ // Check that we are always entering from Dart code.
+ __ LoadFromOffset(kWord, R6, CTX, Isolate::vm_tag_offset());
+ __ CompareImmediate(R6, VMTag::kScriptTagId);
+ __ b(&ok, EQ);
+ __ Stop("Not coming from Dart code.");
+ __ Bind(&ok);
+ }
+#endif
+
+ // Mark that the isolate is executing VM code.
+ __ LoadImmediate(R6, VMTag::kVMTagId);
+ __ StoreToOffset(kWord, R6, CTX, Isolate::vm_tag_offset());
+
// Reserve space for arguments and align frame before entering C++ world.
// NativeArguments are passed in registers.
ASSERT(sizeof(NativeArguments) == 4 * kWordSize);
@@ -84,6 +100,10 @@ void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) {
// Call runtime or redirection via simulator.
__ blx(R5);
+ // Mark that the isolate is executing Dart code.
+ __ LoadImmediate(R2, VMTag::kScriptTagId);
+ __ StoreToOffset(kWord, R2, CTX, Isolate::vm_tag_offset());
+
// Reset exit frame information in Isolate structure.
__ LoadImmediate(R2, 0);
__ StoreToOffset(kWord, R2, CTX, Isolate::top_exit_frame_info_offset());
@@ -153,6 +173,21 @@ void StubCode::GenerateCallNativeCFunctionStub(Assembler* assembler) {
// Cache Isolate pointer into CTX while executing native code.
__ mov(CTX, ShifterOperand(R0));
+#if defined(DEBUG)
+ { Label ok;
+ // Check that we are always entering from Dart code.
+ __ LoadFromOffset(kWord, R6, CTX, Isolate::vm_tag_offset());
+ __ CompareImmediate(R6, VMTag::kScriptTagId);
+ __ b(&ok, EQ);
+ __ Stop("Not coming from Dart code.");
+ __ Bind(&ok);
+ }
+#endif
+
+ // Mark that the isolate is executing Native code.
+ __ LoadImmediate(R6, VMTag::kRuntimeNativeTagId);
+ __ StoreToOffset(kWord, R6, CTX, Isolate::vm_tag_offset());
+
// Reserve space for the native arguments structure passed on the stack (the
// outgoing pointer parameter to the native arguments structure is passed in
// R0) and align frame before entering the C++ world.
@@ -206,6 +241,10 @@ void StubCode::GenerateCallNativeCFunctionStub(Assembler* assembler) {
__ Bind(&done);
+ // Mark that the isolate is executing Dart code.
+ __ LoadImmediate(R2, VMTag::kScriptTagId);
+ __ StoreToOffset(kWord, R2, CTX, Isolate::vm_tag_offset());
+
// Reset exit frame information in Isolate structure.
__ LoadImmediate(R2, 0);
__ StoreToOffset(kWord, R2, CTX, Isolate::top_exit_frame_info_offset());
@@ -256,6 +295,21 @@ void StubCode::GenerateCallBootstrapCFunctionStub(Assembler* assembler) {
// Cache Isolate pointer into CTX while executing native code.
__ mov(CTX, ShifterOperand(R0));
+#if defined(DEBUG)
+ { Label ok;
+ // Check that we are always entering from Dart code.
+ __ LoadFromOffset(kWord, R6, CTX, Isolate::vm_tag_offset());
+ __ CompareImmediate(R6, VMTag::kScriptTagId);
+ __ b(&ok, EQ);
+ __ Stop("Not coming from Dart code.");
+ __ Bind(&ok);
+ }
+#endif
+
+ // Mark that the isolate is executing Native code.
+ __ LoadImmediate(R6, VMTag::kRuntimeNativeTagId);
+ __ StoreToOffset(kWord, R6, CTX, Isolate::vm_tag_offset());
+
// Reserve space for the native arguments structure passed on the stack (the
// outgoing pointer parameter to the native arguments structure is passed in
// R0) and align frame before entering the C++ world.
@@ -287,6 +341,10 @@ void StubCode::GenerateCallBootstrapCFunctionStub(Assembler* assembler) {
// Call native function or redirection via simulator.
__ blx(R5);
+ // Mark that the isolate is executing Dart code.
+ __ LoadImmediate(R2, VMTag::kScriptTagId);
+ __ StoreToOffset(kWord, R2, CTX, Isolate::vm_tag_offset());
+
// Reset exit frame information in Isolate structure.
__ LoadImmediate(R2, 0);
__ StoreToOffset(kWord, R2, CTX, Isolate::top_exit_frame_info_offset());
@@ -836,6 +894,15 @@ void StubCode::GenerateInvokeDartCodeStub(Assembler* assembler) {
// Load Isolate pointer from Context structure into temporary register R8.
__ ldr(R8, FieldAddress(CTX, Context::isolate_offset()));
+ // Save the current VMTag on the stack.
+ ASSERT(kSavedVMTagSlotFromEntryFp == -25);
+ __ LoadFromOffset(kWord, R5, R8, Isolate::vm_tag_offset());
+ __ Push(R5);
+
+ // Mark that the isolate is executing Dart code.
+ __ LoadImmediate(R5, VMTag::kScriptTagId);
+ __ StoreToOffset(kWord, R5, R8, Isolate::vm_tag_offset());
+
// Save the top exit frame info. Use R5 as a temporary register.
// StackFrameIterator reads the top exit frame info saved in this frame.
__ LoadFromOffset(kWord, R5, R8, Isolate::top_exit_frame_info_offset());
@@ -851,8 +918,8 @@ void StubCode::GenerateInvokeDartCodeStub(Assembler* assembler) {
// The constants kSavedContextSlotFromEntryFp and
// kExitLinkSlotFromEntryFp must be kept in sync with the code below.
- ASSERT(kExitLinkSlotFromEntryFp == -25);
- ASSERT(kSavedContextSlotFromEntryFp == -26);
+ ASSERT(kExitLinkSlotFromEntryFp == -26);
+ ASSERT(kSavedContextSlotFromEntryFp == -27);
__ PushList((1 << R4) | (1 << R5));
// Load arguments descriptor array into R4, which is passed to Dart code.
@@ -902,6 +969,10 @@ void StubCode::GenerateInvokeDartCodeStub(Assembler* assembler) {
__ StoreToOffset(kWord, R4, CTX, Isolate::top_context_offset());
__ StoreToOffset(kWord, R5, CTX, Isolate::top_exit_frame_info_offset());
+ // Restore the current VMTag from the stack.
+ __ Pop(R4);
+ __ StoreToOffset(kWord, R4, CTX, Isolate::vm_tag_offset());
+
// Restore C++ ABI callee-saved registers.
// Restore FPU registers. 2 D registers per Q register.
__ vldmd(IA_W, SP, firstd, 2 * kAbiPreservedFpuRegCount);
« no previous file with comments | « runtime/vm/stub_code.h ('k') | runtime/vm/stub_code_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698