OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "test/cctest/compiler/function-tester.h" | 7 #include "test/cctest/compiler/function-tester.h" |
8 | 8 |
9 using namespace v8::internal; | 9 using namespace v8::internal; |
10 using namespace v8::internal::compiler; | 10 using namespace v8::internal::compiler; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 return strcmp(name, COUNTER_NAME) == 0 ? &counter : nullptr; | 56 return strcmp(name, COUNTER_NAME) == 0 ? &counter : nullptr; |
57 } | 57 } |
58 | 58 |
59 | 59 |
60 TEST(IncrementStatsCounter) { | 60 TEST(IncrementStatsCounter) { |
61 FLAG_turbo_deoptimization = true; | 61 FLAG_turbo_deoptimization = true; |
62 FLAG_native_code_counters = true; | 62 FLAG_native_code_counters = true; |
63 reinterpret_cast<v8::Isolate*>(CcTest::InitIsolateOnce()) | 63 reinterpret_cast<v8::Isolate*>(CcTest::InitIsolateOnce()) |
64 ->SetCounterFunction(LookupCounter); | 64 ->SetCounterFunction(LookupCounter); |
65 FunctionTester T( | 65 FunctionTester T( |
66 "(function() { %_IncrementStatsCounter(\"" COUNTER_NAME "\"); })", flags); | 66 "(function() { %_IncrementStatsCounter('" COUNTER_NAME "'); })", flags); |
67 StatsCounter counter(T.main_isolate(), COUNTER_NAME); | 67 StatsCounter counter(T.main_isolate(), COUNTER_NAME); |
68 if (!counter.Enabled()) return; | 68 if (!counter.Enabled()) return; |
69 | 69 |
70 int old_value = *counter.GetInternalPointer(); | 70 int old_value = *counter.GetInternalPointer(); |
71 T.CheckCall(T.undefined()); | 71 T.CheckCall(T.undefined()); |
72 CHECK_EQ(old_value + 1, *counter.GetInternalPointer()); | 72 CHECK_EQ(old_value + 1, *counter.GetInternalPointer()); |
73 } | 73 } |
74 | 74 |
75 #undef COUNTER_NAME | 75 #undef COUNTER_NAME |
76 | 76 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 string->SeqOneByteStringSet(0, 'b'); | 228 string->SeqOneByteStringSet(0, 'b'); |
229 string->SeqOneByteStringSet(1, 'a'); | 229 string->SeqOneByteStringSet(1, 'a'); |
230 string->SeqOneByteStringSet(2, 'r'); | 230 string->SeqOneByteStringSet(2, 'r'); |
231 T.Call(T.Val(1), string); | 231 T.Call(T.Val(1), string); |
232 CHECK_EQ('b', string->SeqOneByteStringGet(0)); | 232 CHECK_EQ('b', string->SeqOneByteStringGet(0)); |
233 CHECK_EQ('X', string->SeqOneByteStringGet(1)); | 233 CHECK_EQ('X', string->SeqOneByteStringGet(1)); |
234 CHECK_EQ('r', string->SeqOneByteStringGet(2)); | 234 CHECK_EQ('r', string->SeqOneByteStringGet(2)); |
235 } | 235 } |
236 | 236 |
237 | 237 |
| 238 TEST(NewConsString) { |
| 239 FLAG_turbo_deoptimization = true; |
| 240 FunctionTester T( |
| 241 "(function() { " |
| 242 " return %_NewConsString(14, true, 'abcdefghi', 'jklmn');" |
| 243 " })", |
| 244 flags); |
| 245 |
| 246 T.CheckCall(T.Val("abcdefghijklmn")); |
| 247 } |
| 248 |
| 249 |
238 TEST(SetValueOf) { | 250 TEST(SetValueOf) { |
239 FLAG_turbo_deoptimization = true; | 251 FLAG_turbo_deoptimization = true; |
240 FunctionTester T("(function(a,b) { return %_SetValueOf(a,b); })", flags); | 252 FunctionTester T("(function(a,b) { return %_SetValueOf(a,b); })", flags); |
241 | 253 |
242 T.CheckCall(T.Val("a"), T.NewObject("(new String)"), T.Val("a")); | 254 T.CheckCall(T.Val("a"), T.NewObject("(new String)"), T.Val("a")); |
243 T.CheckCall(T.Val(123), T.NewObject("(new Number)"), T.Val(123)); | 255 T.CheckCall(T.Val(123), T.NewObject("(new Number)"), T.Val(123)); |
244 T.CheckCall(T.Val("x"), T.undefined(), T.Val("x")); | 256 T.CheckCall(T.Val("x"), T.undefined(), T.Val("x")); |
245 } | 257 } |
246 | 258 |
247 | 259 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 | 353 |
342 TEST(ValueOf) { | 354 TEST(ValueOf) { |
343 FLAG_turbo_deoptimization = true; | 355 FLAG_turbo_deoptimization = true; |
344 FunctionTester T("(function(a) { return %_ValueOf(a); })", flags); | 356 FunctionTester T("(function(a) { return %_ValueOf(a); })", flags); |
345 | 357 |
346 T.CheckCall(T.Val("a"), T.Val("a")); | 358 T.CheckCall(T.Val("a"), T.Val("a")); |
347 T.CheckCall(T.Val("b"), T.NewObject("(new String('b'))")); | 359 T.CheckCall(T.Val("b"), T.NewObject("(new String('b'))")); |
348 T.CheckCall(T.Val(123), T.Val(123)); | 360 T.CheckCall(T.Val(123), T.Val(123)); |
349 T.CheckCall(T.Val(456), T.NewObject("(new Number(456))")); | 361 T.CheckCall(T.Val(456), T.NewObject("(new Number(456))")); |
350 } | 362 } |
OLD | NEW |