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

Side by Side Diff: test/cctest/test-regressions-sh4.cc

Issue 11275184: First draft of the sh4 port Base URL: http://github.com/v8/v8.git@master
Patch Set: Use GYP and fixe some typos Created 8 years, 1 month 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
« no previous file with comments | « test/cctest/test-regexp.cc ('k') | test/cctest/test-sh4.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 #include <stdlib.h>
29
30 #include "v8.h"
31
32 #include "api.h"
33 #include "cctest.h"
34 #include "frames-inl.h"
35 #include "string-stream.h"
36
37 using ::v8::ObjectTemplate;
38 using ::v8::Value;
39 using ::v8::Context;
40 using ::v8::Local;
41 using ::v8::String;
42 using ::v8::Script;
43 using ::v8::Function;
44 using ::v8::AccessorInfo;
45 using ::v8::Extension;
46
47 // Simply returns the undefined object
48 static v8::Handle<Value> CallBack(Local<String> name,
49 const AccessorInfo& info) {
50 return v8::Undefined();
51 }
52
53 // Regression test for a defect in -use-ic mode.
54 // The bug returns a:
55 // Fatal error in src/objects.h, line 732
56 // CHECK(!IsFailure()) failed
57 // The problem was in sh4 MacroAssembler::TryCallApiFunctionAndReturn()
58 // that used r0 as scratch register for DirectCEntryStub().
59 // This scratch must not be a return value register.
60 // Note: 3 iterations of the loop are necessary to exhibit the issue.
61 THREADED_TEST(IssueLoadCallback) {
62 v8::HandleScope scope;
63 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
64 i::StringStream::ClearMentionedObjectCache();
65 obj->SetAccessor(v8_str("xxx"), CallBack);
66 LocalContext env;
67 env->Global()->Set(v8_str("obj"), obj->NewInstance());
68 Script::Compile(String::New(
69 "function foo() {"
70 " return obj.xxx;"
71 "}"
72 "for (var i = 0; i < 3; i++) {"
73 " foo();"
74 "}"))->Run();
75 }
76
77 // Regression test for a defect in -use-ic mode.
78 // Handling of non-smi value on sh4 was wrong in
79 // KeyedLoadStubCompiler::GenerateLoadExternalArray().
80 // Used to return -1 instead of INT_MAX.
81 // Note: 3 iterations of the loop are necessary to exhibit the issue.
82 THREADED_TEST(IssueKeyedLoadExtIntArray) {
83 v8::HandleScope scope;
84 LocalContext context;
85 v8::Handle<v8::Object> obj = v8::Object::New();
86 int kElementCount = 1;
87 int32_t* array_data =
88 static_cast<int32_t*>(malloc(kElementCount * sizeof(int32_t)));
89 array_data[0] = 2147483647; // Initialize the first element with MAX_INT
90 obj->SetIndexedPropertiesToExternalArrayData(array_data,
91 v8::kExternalIntArray,
92 kElementCount);
93 context->Global()->Set(v8_str("ext_array"), obj);
94 const char* boundary_program =
95 "var res = 0;"
96 "for (var i = 0; i < 3; i++) {"
97 " res = ext_array[0];" // Get the first element
98 "}"
99 "res;";
100 v8::Handle<v8::Value> result = CompileRun(boundary_program);
101 CHECK_EQ((int64_t)2147483647, result->IntegerValue());
102 }
103
104 // Regression test for a defect in the actual number of argument count.
105 // Handling of actual arguments was wrong when the arguments number
106 // was greater than the formal arguments number in
107 // Builtins::Generate_ArgumentsAdaptorTrampoline().
108 // Used to return always 0 (formal arguments number of Foo)
109 // in this test instead of the actual arguments number.
110 THREADED_TEST(IssueActualArgumentsNum) {
111 v8::HandleScope scope;
112 LocalContext context;
113 CompileRun(
114 "function Foo() {"
115 " return arguments.length;"
116 "}");
117 Local<Function> Foo =
118 Local<Function>::Cast(context->Global()->Get(v8_str("Foo")));
119
120 v8::Handle<Value>* args0 = NULL;
121 Local<v8::Integer> l0 = Local<v8::Integer>::Cast(Foo->Call(Foo, 0, args0));
122 CHECK_EQ((int64_t)0, l0->Value());
123
124 v8::Handle<Value> args1[] = { v8_num(1.1) };
125 Local<v8::Integer> l1 = Local<v8::Integer>::Cast(Foo->Call(Foo, 1, args1));
126 CHECK_EQ((int64_t)1, l1->Value());
127
128 v8::Handle<Value> args2[] = { v8_num(2.2),
129 v8_num(3.3) };
130 Local<v8::Integer> l2 = Local<v8::Integer>::Cast(Foo->Call(Foo, 2, args2));
131 CHECK_EQ((int64_t)2, l2->Value());
132
133 v8::Handle<Value> args3[] = { v8_num(4.4),
134 v8_num(5.5),
135 v8_num(6.6) };
136 Local<v8::Integer> l3 = Local<v8::Integer>::Cast(Foo->Call(Foo, 3, args3));
137 CHECK_EQ((int64_t)3, l3->Value());
138
139 v8::Handle<Value> args4[] = { v8_num(7.7),
140 v8_num(8.8),
141 v8_num(9.9),
142 v8_num(10.11) };
143 Local<v8::Integer> l4 = Local<v8::Integer>::Cast(Foo->Call(Foo, 4, args4));
144 CHECK_EQ((int64_t)4, l4->Value());
145 }
146
147 // Extracted from test-api/CatchStackOverflow
148 // Fails with a sigsegv on sh4 QEMU.
149 // Reduce the stack size (in Kb) when running cctest, for instance: cctest
150 // -stack_size=256 ...
151 TEST(IssueCatchStackOverflow) {
152 v8::HandleScope scope;
153 LocalContext context;
154 v8::TryCatch try_catch;
155 v8::Handle<v8::Script> script = v8::Script::Compile(v8::String::New(
156 "function f() {"
157 " return f();"
158 "}"
159 ""
160 "f();"));
161 v8::Handle<v8::Value> result = script->Run();
162 CHECK(result.IsEmpty());
163 }
164
165
166 // Extracted from test-api/Regress528
167 // Does not return the correct line source information in the exception.
168 // Returns 0 as line number instead of 1.
169 // The problem was in assembler-sh4 where one must call
170 // positions_recorder()->WriteRecordedPositions() for all jsr/jmp
171 TEST(IssueTryCatchSourceInfo) {
172 v8::HandleScope scope;
173 LocalContext context;
174 v8::TryCatch try_catch;
175 const char* source_exception = "function f(){throw 1;} f()";
176 CompileRun(source_exception);
177 CHECK(try_catch.HasCaught());
178 v8::Handle<v8::Message> message = try_catch.Message();
179 CHECK(!message.IsEmpty());
180 CHECK_EQ(1, message->GetLineNumber());
181 }
182
183
184 // Extracted from mjsunit/stack-traces.js
185 // Does not return the correct eval location
186 // when compiled with debuggersupport=off.
187 // This has been corrected in compiler.cc/MakeFunctionInfo()
188 // where the code was guarded by ENABLE_DEBUGGER_SUPPORT.
189 // This guard was moved such tha eval location is
190 // correctly setup.
191 TEST(IssueEvalStackTrace) {
192 v8::HandleScope scope;
193 LocalContext context;
194 v8::TryCatch try_catch;
195 v8::Handle<v8::Script> script =
196 v8::Script::Compile(v8::String::New(
197 "try { eval(\"FAIL\") } catch(e) { e.stack }"));
198 v8::internal::Handle<v8::internal::String> result =
199 v8::Utils::OpenHandle(*v8::Handle<v8::String>::Cast(script->Run()));
200 // Check that the returned string contains an eval location
201 CHECK(strstr(*(*result)->ToCString(), "eval at") != NULL);
202 }
OLDNEW
« no previous file with comments | « test/cctest/test-regexp.cc ('k') | test/cctest/test-sh4.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698