| 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/debug.h" | 9 #include "src/debug/debug.h" |
| 10 #include "src/execution.h" | 10 #include "src/execution.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 4 * TypeFeedbackMetadata::GetSlotSize( | 88 4 * TypeFeedbackMetadata::GetSlotSize( |
| 89 FeedbackVectorSlotKind::CALL_IC), | 89 FeedbackVectorSlotKind::CALL_IC), |
| 90 index); | 90 index); |
| 91 CHECK_EQ(helper.slot(7), vector->ToSlot(index)); | 91 CHECK_EQ(helper.slot(7), vector->ToSlot(index)); |
| 92 | 92 |
| 93 CHECK_EQ(TypeFeedbackVector::kReservedIndexCount + 3 + | 93 CHECK_EQ(TypeFeedbackVector::kReservedIndexCount + 3 + |
| 94 5 * TypeFeedbackMetadata::GetSlotSize( | 94 5 * TypeFeedbackMetadata::GetSlotSize( |
| 95 FeedbackVectorSlotKind::CALL_IC), | 95 FeedbackVectorSlotKind::CALL_IC), |
| 96 vector->length()); | 96 vector->length()); |
| 97 } | 97 } |
| 98 | |
| 99 { | |
| 100 FeedbackVectorSpec spec(&zone); | |
| 101 spec.AddGeneralSlot(); | |
| 102 spec.AddCreateClosureSlot(5); | |
| 103 spec.AddGeneralSlot(); | |
| 104 vector = NewTypeFeedbackVector(isolate, &spec); | |
| 105 FeedbackVectorHelper helper(vector); | |
| 106 CHECK_EQ(1, TypeFeedbackMetadata::GetSlotSize( | |
| 107 FeedbackVectorSlotKind::CREATE_CLOSURE)); | |
| 108 FeedbackVectorSlot slot = helper.slot(1); | |
| 109 FixedArray* array = FixedArray::cast(vector->Get(slot)); | |
| 110 CHECK_EQ(5, array->length()); | |
| 111 CHECK_EQ(5, vector->GetParameter(slot)); | |
| 112 CHECK_EQ(array->get(0), *factory->undefined_value()); | |
| 113 } | |
| 114 } | 98 } |
| 115 | 99 |
| 116 | 100 |
| 117 // IC slots need an encoding to recognize what is in there. | 101 // IC slots need an encoding to recognize what is in there. |
| 118 TEST(VectorICMetadata) { | 102 TEST(VectorICMetadata) { |
| 119 LocalContext context; | 103 LocalContext context; |
| 120 v8::HandleScope scope(context->GetIsolate()); | 104 v8::HandleScope scope(context->GetIsolate()); |
| 121 Isolate* isolate = CcTest::i_isolate(); | 105 Isolate* isolate = CcTest::i_isolate(); |
| 122 Zone zone(isolate->allocator(), ZONE_NAME); | 106 Zone zone(isolate->allocator(), ZONE_NAME); |
| 123 | 107 |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 // There should be one IC slot. | 583 // There should be one IC slot. |
| 600 Handle<TypeFeedbackVector> feedback_vector(f->feedback_vector()); | 584 Handle<TypeFeedbackVector> feedback_vector(f->feedback_vector()); |
| 601 FeedbackVectorHelper helper(feedback_vector); | 585 FeedbackVectorHelper helper(feedback_vector); |
| 602 CHECK_EQ(1, helper.slot_count()); | 586 CHECK_EQ(1, helper.slot_count()); |
| 603 FeedbackVectorSlot slot(0); | 587 FeedbackVectorSlot slot(0); |
| 604 StoreICNexus nexus(feedback_vector, slot); | 588 StoreICNexus nexus(feedback_vector, slot); |
| 605 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); | 589 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); |
| 606 } | 590 } |
| 607 | 591 |
| 608 } // namespace | 592 } // namespace |
| OLD | NEW |