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

Unified Diff: runtime/vm/code_patcher_x64_test.cc

Issue 8984003: Port code generator to x64. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/code_patcher_x64.cc ('k') | runtime/vm/compiler_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/code_patcher_x64_test.cc
===================================================================
--- runtime/vm/code_patcher_x64_test.cc (revision 0)
+++ runtime/vm/code_patcher_x64_test.cc (revision 0)
@@ -0,0 +1,86 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#include "vm/globals.h"
+#if defined(TARGET_ARCH_X64)
+
+#include "vm/assembler.h"
+#include "vm/code_generator.h"
+#include "vm/code_patcher.h"
+#include "vm/dart_entry.h"
+#include "vm/ic_data.h"
+#include "vm/instructions.h"
+#include "vm/native_entry.h"
+#include "vm/native_entry_test.h"
+#include "vm/stub_code.h"
+#include "vm/unit_test.h"
+
+namespace dart {
+
+static const intptr_t kPos = 1; // Dummy token index in non-existing source.
+
+CODEGEN_TEST_GENERATE(NativePatchStaticCall, test) {
+ SequenceNode* node_seq = test->node_sequence();
+ const int num_params = 0;
+ const bool has_opt_params = false;
+ const String& native_name =
+ String::ZoneHandle(String::NewSymbol("TestStaticCallPatching"));
+ NativeFunction native_function = reinterpret_cast<NativeFunction>(
+ NATIVE_ENTRY_FUNCTION(TestStaticCallPatching));
+ node_seq->Add(new ReturnNode(kPos,
+ new NativeBodyNode(kPos,
+ native_name,
+ native_function,
+ num_params,
+ has_opt_params)));
+}
+
+CODEGEN_TEST2_GENERATE(PatchStaticCall, function, test) {
+ SequenceNode* node_seq = test->node_sequence();
+ ArgumentListNode* arguments = new ArgumentListNode(kPos);
+ node_seq->Add(new ReturnNode(kPos,
+ new StaticCallNode(kPos, function, arguments)));
+}
+
+CODEGEN_TEST2_RUN(PatchStaticCall, NativePatchStaticCall, Instance::null());
+
+#define __ assembler->
+
+ASSEMBLER_TEST_GENERATE(IcDataAccess, assembler) {
+ const String& function_name = String::Handle(String::New("Vermicelles"));
+ ICData ic_data(function_name, 1);
+ EXPECT(!Array::Handle(ic_data.data()).IsNull());
+ __ LoadObject(RBX, Array::ZoneHandle(ic_data.data()));
+ __ LoadObject(R10, CodeGenerator::ArgumentsDescriptor(1, Array::Handle()));
+ ExternalLabel target_label(
+ "InlineCache", StubCode::OneArgCheckInlineCacheEntryPoint());
+ __ call(&target_label);
+ __ ret();
+}
+
+
+ASSEMBLER_TEST_RUN(IcDataAccess, entry) {
+ uword return_address = entry + CodePatcher::InstanceCallSizeInBytes();
+ const Array& array = Array::Handle(
+ CodePatcher::GetInstanceCallIcDataAt(return_address));
+ EXPECT(!array.IsNull());
+ ICData ic_data(array);
+ EXPECT_STREQ("Vermicelles",
+ String::Handle(ic_data.FunctionName()).ToCString());
+ EXPECT_EQ(1, ic_data.NumberOfArgumentsChecked());
+ EXPECT_EQ(0, ic_data.NumberOfChecks());
+ const String& new_function_name = String::Handle(String::New("Rigi"));
+ ICData new_ic_data(new_function_name, 1);
+ EXPECT_STREQ("Rigi", String::Handle(new_ic_data.FunctionName()).ToCString());
+ CodePatcher::SetInstanceCallIcDataAt(return_address,
+ Array::ZoneHandle(new_ic_data.data()));
+ const Array& new_array = Array::Handle(
+ CodePatcher::GetInstanceCallIcDataAt(return_address));
+ ICData test_ic_data(new_array);
+ EXPECT_STREQ("Rigi", String::Handle(test_ic_data.FunctionName()).ToCString());
+}
+
+} // namespace dart
+
+#endif // TARGET_ARCH_X64
« no previous file with comments | « runtime/vm/code_patcher_x64.cc ('k') | runtime/vm/compiler_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698