| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 FunctionTester T("(function(a) { return %_HeapObjectGetMap(a); })", flags); | 42 FunctionTester T("(function(a) { return %_HeapObjectGetMap(a); })", flags); |
| 43 | 43 |
| 44 Factory* factory = T.main_isolate()->factory(); | 44 Factory* factory = T.main_isolate()->factory(); |
| 45 T.CheckCall(factory->null_map(), T.null()); | 45 T.CheckCall(factory->null_map(), T.null()); |
| 46 T.CheckCall(factory->undefined_map(), T.undefined()); | 46 T.CheckCall(factory->undefined_map(), T.undefined()); |
| 47 T.CheckCall(factory->heap_number_map(), T.Val(3.1415)); | 47 T.CheckCall(factory->heap_number_map(), T.Val(3.1415)); |
| 48 T.CheckCall(factory->symbol_map(), factory->NewSymbol()); | 48 T.CheckCall(factory->symbol_map(), factory->NewSymbol()); |
| 49 } | 49 } |
| 50 | 50 |
| 51 | 51 |
| 52 #define COUNTER_NAME "hurz" |
| 53 |
| 54 static int* LookupCounter(const char* name) { |
| 55 static int counter = 1234; |
| 56 return strcmp(name, COUNTER_NAME) == 0 ? &counter : nullptr; |
| 57 } |
| 58 |
| 59 |
| 60 TEST(IncrementStatsCounter) { |
| 61 FLAG_turbo_deoptimization = true; |
| 62 FLAG_native_code_counters = true; |
| 63 reinterpret_cast<v8::Isolate*>(CcTest::InitIsolateOnce()) |
| 64 ->SetCounterFunction(LookupCounter); |
| 65 FunctionTester T( |
| 66 "(function() { %_IncrementStatsCounter(\"" COUNTER_NAME "\"); })", flags); |
| 67 StatsCounter counter(T.main_isolate(), COUNTER_NAME); |
| 68 if (!counter.Enabled()) return; |
| 69 |
| 70 int old_value = *counter.GetInternalPointer(); |
| 71 T.CheckCall(T.undefined()); |
| 72 CHECK_EQ(old_value + 1, *counter.GetInternalPointer()); |
| 73 } |
| 74 |
| 75 #undef COUNTER_NAME |
| 76 |
| 77 |
| 52 TEST(IsArray) { | 78 TEST(IsArray) { |
| 53 FLAG_turbo_deoptimization = true; | 79 FLAG_turbo_deoptimization = true; |
| 54 FunctionTester T("(function(a) { return %_IsArray(a); })", flags); | 80 FunctionTester T("(function(a) { return %_IsArray(a); })", flags); |
| 55 | 81 |
| 56 T.CheckFalse(T.NewObject("(function() {})")); | 82 T.CheckFalse(T.NewObject("(function() {})")); |
| 57 T.CheckTrue(T.NewObject("([1])")); | 83 T.CheckTrue(T.NewObject("([1])")); |
| 58 T.CheckFalse(T.NewObject("({})")); | 84 T.CheckFalse(T.NewObject("({})")); |
| 59 T.CheckFalse(T.NewObject("(/x/)")); | 85 T.CheckFalse(T.NewObject("(/x/)")); |
| 60 T.CheckFalse(T.undefined()); | 86 T.CheckFalse(T.undefined()); |
| 61 T.CheckFalse(T.null()); | 87 T.CheckFalse(T.null()); |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 | 341 |
| 316 TEST(ValueOf) { | 342 TEST(ValueOf) { |
| 317 FLAG_turbo_deoptimization = true; | 343 FLAG_turbo_deoptimization = true; |
| 318 FunctionTester T("(function(a) { return %_ValueOf(a); })", flags); | 344 FunctionTester T("(function(a) { return %_ValueOf(a); })", flags); |
| 319 | 345 |
| 320 T.CheckCall(T.Val("a"), T.Val("a")); | 346 T.CheckCall(T.Val("a"), T.Val("a")); |
| 321 T.CheckCall(T.Val("b"), T.NewObject("(new String('b'))")); | 347 T.CheckCall(T.Val("b"), T.NewObject("(new String('b'))")); |
| 322 T.CheckCall(T.Val(123), T.Val(123)); | 348 T.CheckCall(T.Val(123), T.Val(123)); |
| 323 T.CheckCall(T.Val(456), T.NewObject("(new Number(456))")); | 349 T.CheckCall(T.Val(456), T.NewObject("(new Number(456))")); |
| 324 } | 350 } |
| OLD | NEW |