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 #include "test/cctest/cctest.h" | 6 #include "test/cctest/cctest.h" |
7 | 7 |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/debug.h" | 9 #include "src/debug.h" |
10 #include "src/execution.h" | 10 #include "src/execution.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 "function f(a) { a(); } f(foo);"); | 226 "function f(a) { a(); } f(foo);"); |
227 Handle<JSFunction> f = v8::Utils::OpenHandle( | 227 Handle<JSFunction> f = v8::Utils::OpenHandle( |
228 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))); | 228 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))); |
229 // There should be one IC. | 229 // There should be one IC. |
230 Handle<TypeFeedbackVector> feedback_vector = | 230 Handle<TypeFeedbackVector> feedback_vector = |
231 Handle<TypeFeedbackVector>(f->shared()->feedback_vector(), isolate); | 231 Handle<TypeFeedbackVector>(f->shared()->feedback_vector(), isolate); |
232 FeedbackVectorICSlot slot(0); | 232 FeedbackVectorICSlot slot(0); |
233 CallICNexus nexus(feedback_vector, slot); | 233 CallICNexus nexus(feedback_vector, slot); |
234 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); | 234 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); |
235 // CallIC doesn't return map feedback. | 235 // CallIC doesn't return map feedback. |
236 CHECK_EQ(NULL, nexus.FindFirstMap()); | 236 CHECK(!nexus.FindFirstMap()); |
237 | 237 |
238 CompileRun("f(function() { return 16; })"); | 238 CompileRun("f(function() { return 16; })"); |
239 CHECK_EQ(GENERIC, nexus.StateFromFeedback()); | 239 CHECK_EQ(GENERIC, nexus.StateFromFeedback()); |
240 | 240 |
241 // After a collection, state should be reset to UNINITIALIZED. | 241 // After a collection, state should be reset to UNINITIALIZED. |
242 heap->CollectAllGarbage(i::Heap::kNoGCFlags); | 242 heap->CollectAllGarbage(i::Heap::kNoGCFlags); |
243 CHECK_EQ(UNINITIALIZED, nexus.StateFromFeedback()); | 243 CHECK_EQ(UNINITIALIZED, nexus.StateFromFeedback()); |
244 | 244 |
245 // Array is special. It will remain monomorphic across gcs and it contains an | 245 // Array is special. It will remain monomorphic across gcs and it contains an |
246 // AllocationSite. | 246 // AllocationSite. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 | 292 |
293 CompileRun("f({ blarg: 3, torino: 10, foo: 2 })"); | 293 CompileRun("f({ blarg: 3, torino: 10, foo: 2 })"); |
294 CHECK_EQ(POLYMORPHIC, nexus.StateFromFeedback()); | 294 CHECK_EQ(POLYMORPHIC, nexus.StateFromFeedback()); |
295 MapHandleList maps; | 295 MapHandleList maps; |
296 nexus.FindAllMaps(&maps); | 296 nexus.FindAllMaps(&maps); |
297 CHECK_EQ(4, maps.length()); | 297 CHECK_EQ(4, maps.length()); |
298 | 298 |
299 // Finally driven megamorphic. | 299 // Finally driven megamorphic. |
300 CompileRun("f({ blarg: 3, gran: 3, torino: 10, foo: 2 })"); | 300 CompileRun("f({ blarg: 3, gran: 3, torino: 10, foo: 2 })"); |
301 CHECK_EQ(MEGAMORPHIC, nexus.StateFromFeedback()); | 301 CHECK_EQ(MEGAMORPHIC, nexus.StateFromFeedback()); |
302 CHECK_EQ(NULL, nexus.FindFirstMap()); | 302 CHECK(!nexus.FindFirstMap()); |
303 | 303 |
304 // After a collection, state should not be reset to PREMONOMORPHIC. | 304 // After a collection, state should not be reset to PREMONOMORPHIC. |
305 heap->CollectAllGarbage(i::Heap::kNoGCFlags); | 305 heap->CollectAllGarbage(i::Heap::kNoGCFlags); |
306 CHECK_EQ(MEGAMORPHIC, nexus.StateFromFeedback()); | 306 CHECK_EQ(MEGAMORPHIC, nexus.StateFromFeedback()); |
307 } | 307 } |
308 | 308 |
309 | 309 |
310 TEST(VectorLoadICOnSmi) { | 310 TEST(VectorLoadICOnSmi) { |
311 if (i::FLAG_always_opt || !i::FLAG_vector_ics) return; | 311 if (i::FLAG_always_opt || !i::FLAG_vector_ics) return; |
312 CcTest::InitializeVM(); | 312 CcTest::InitializeVM(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 CHECK(number_map_found && o_map_found); | 357 CHECK(number_map_found && o_map_found); |
358 | 358 |
359 // The degree of polymorphism doesn't change. | 359 // The degree of polymorphism doesn't change. |
360 CompileRun("f(100)"); | 360 CompileRun("f(100)"); |
361 CHECK_EQ(POLYMORPHIC, nexus.StateFromFeedback()); | 361 CHECK_EQ(POLYMORPHIC, nexus.StateFromFeedback()); |
362 MapHandleList maps2; | 362 MapHandleList maps2; |
363 nexus.FindAllMaps(&maps2); | 363 nexus.FindAllMaps(&maps2); |
364 CHECK_EQ(2, maps2.length()); | 364 CHECK_EQ(2, maps2.length()); |
365 } | 365 } |
366 } | 366 } |
OLD | NEW |