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

Unified Diff: test/cctest/test-macro-assembler-mips64.cc

Issue 371923006: Add mips64 port. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase Created 6 years, 5 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 | « test/cctest/test-heap.cc ('k') | test/cctest/test-regexp.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-macro-assembler-mips64.cc
diff --git a/test/cctest/test-macro-assembler-mips.cc b/test/cctest/test-macro-assembler-mips64.cc
similarity index 62%
copy from test/cctest/test-macro-assembler-mips.cc
copy to test/cctest/test-macro-assembler-mips64.cc
index 33a4611540f427cb800d1a60ded88c47f0a93391..eef658de67fef55ccada02340cdb5a43b14f20d6 100644
--- a/test/cctest/test-macro-assembler-mips.cc
+++ b/test/cctest/test-macro-assembler-mips64.cc
@@ -31,13 +31,13 @@
#include "test/cctest/cctest.h"
#include "src/macro-assembler.h"
-#include "src/mips/macro-assembler-mips.h"
-#include "src/mips/simulator-mips.h"
+#include "src/mips64/macro-assembler-mips64.h"
+#include "src/mips64/simulator-mips64.h"
using namespace v8::internal;
-typedef void* (*F)(int x, int y, int p2, int p3, int p4);
+typedef void* (*F)(int64_t x, int64_t y, int p2, int p3, int p4);
#define __ masm->
@@ -86,11 +86,11 @@ TEST(CopyBytes) {
// Code to be generated: The stuff in CopyBytes followed by a store of a0 and
// a1, respectively.
__ CopyBytes(a0, a1, a2, a3);
- __ li(a2, Operand(reinterpret_cast<int>(&a0_)));
- __ li(a3, Operand(reinterpret_cast<int>(&a1_)));
- __ sw(a0, MemOperand(a2));
+ __ li(a2, Operand(reinterpret_cast<int64_t>(&a0_)));
+ __ li(a3, Operand(reinterpret_cast<int64_t>(&a1_)));
+ __ sd(a0, MemOperand(a2));
__ jr(ra);
- __ sw(a1, MemOperand(a3));
+ __ sd(a1, MemOperand(a3));
CodeDesc desc;
masm->GetCode(&desc);
@@ -111,8 +111,9 @@ TEST(CopyBytes) {
for (byte* dest = dest_buffer; dest < dest_buffer + fuzz; dest++) {
memset(dest_buffer, 0, data_size);
CHECK(dest + size < dest_buffer + data_size);
- (void) CALL_GENERATED_CODE(f, reinterpret_cast<int>(src),
- reinterpret_cast<int>(dest), size, 0, 0);
+ (void) CALL_GENERATED_CODE(f, reinterpret_cast<int64_t>(src),
+ reinterpret_cast<int64_t>(dest),
+ size, 0, 0);
// a0 and a1 should point at the first byte after the copied data.
CHECK_EQ(src + size, a0_);
CHECK_EQ(dest + size, a1_);
@@ -132,47 +133,85 @@ TEST(CopyBytes) {
}
-static void TestNaN(const char *code) {
- // NaN value is different on MIPS and x86 architectures, and TEST(NaNx)
- // tests checks the case where a x86 NaN value is serialized into the
- // snapshot on the simulator during cross compilation.
- v8::HandleScope scope(CcTest::isolate());
- v8::Local<v8::Context> context = CcTest::NewContext(PRINT_EXTENSION);
- v8::Context::Scope context_scope(context);
-
- v8::Local<v8::Script> script = v8::Script::Compile(v8_str(code));
- v8::Local<v8::Object> result = v8::Local<v8::Object>::Cast(script->Run());
- // Have to populate the handle manually, as it's not Cast-able.
- i::Handle<i::JSObject> o =
- v8::Utils::OpenHandle<v8::Object, i::JSObject>(result);
- i::Handle<i::JSArray> array1(reinterpret_cast<i::JSArray*>(*o));
- i::FixedDoubleArray* a = i::FixedDoubleArray::cast(array1->elements());
- double value = a->get_scalar(0);
- CHECK(std::isnan(value) &&
- i::BitCast<uint64_t>(value) ==
- i::BitCast<uint64_t>(
- i::FixedDoubleArray::canonical_not_the_hole_nan_as_double()));
-}
+TEST(LoadConstants) {
+ CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ HandleScope handles(isolate);
+ int64_t refConstants[64];
+ int64_t result[64];
-TEST(NaN0) {
- TestNaN(
- "var result;"
- "for (var i = 0; i < 2; i++) {"
- " result = new Array(Number.NaN, Number.POSITIVE_INFINITY);"
- "}"
- "result;");
-}
+ int64_t mask = 1;
+ for (int i = 0; i < 64; i++) {
+ refConstants[i] = ~(mask << i);
+ }
+ MacroAssembler assembler(isolate, NULL, 0);
+ MacroAssembler* masm = &assembler;
+
+ __ mov(a4, a0);
+ for (int i = 0; i < 64; i++) {
+ // Load constant.
+ __ li(a5, Operand(refConstants[i]));
+ __ sd(a5, MemOperand(a4));
+ __ Daddu(a4, a4, Operand(kPointerSize));
+ }
-TEST(NaN1) {
- TestNaN(
- "var result;"
- "for (var i = 0; i < 2; i++) {"
- " result = [NaN];"
- "}"
- "result;");
+ __ jr(ra);
+ __ nop();
+
+ CodeDesc desc;
+ masm->GetCode(&desc);
+ Handle<Code> code = isolate->factory()->NewCode(
+ desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
+
+ ::F f = FUNCTION_CAST< ::F>(code->entry());
+ (void) CALL_GENERATED_CODE(f, reinterpret_cast<int64_t>(result),
+ 0, 0, 0, 0);
+ // Check results.
+ for (int i = 0; i < 64; i++) {
+ CHECK(refConstants[i] == result[i]);
+ }
}
+TEST(LoadAddress) {
+ CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ HandleScope handles(isolate);
+
+ MacroAssembler assembler(isolate, NULL, 0);
+ MacroAssembler* masm = &assembler;
+ Label to_jump, skip;
+ __ mov(a4, a0);
+
+ __ Branch(&skip);
+ __ bind(&to_jump);
+ __ nop();
+ __ nop();
+ __ jr(ra);
+ __ nop();
+ __ bind(&skip);
+ __ li(a4, Operand(masm->jump_address(&to_jump)), ADDRESS_LOAD);
+ int check_size = masm->InstructionsGeneratedSince(&skip);
+ CHECK_EQ(check_size, 4);
+ __ jr(a4);
+ __ nop();
+ __ stop("invalid");
+ __ stop("invalid");
+ __ stop("invalid");
+ __ stop("invalid");
+ __ stop("invalid");
+
+
+ CodeDesc desc;
+ masm->GetCode(&desc);
+ Handle<Code> code = isolate->factory()->NewCode(
+ desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
+
+ ::F f = FUNCTION_CAST< ::F>(code->entry());
+ (void) CALL_GENERATED_CODE(f, 0, 0, 0, 0, 0);
+ // Check results.
+}
+
#undef __
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/cctest/test-regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698