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

Side by Side Diff: src/objects-inl.h

Issue 409613002: Store both major and minor key on code stubs. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 // Review notes: 5 // Review notes:
6 // 6 //
7 // - The use of macros in these inline functions may seem superfluous 7 // - The use of macros in these inline functions may seem superfluous
8 // but it is absolutely needed to make sure gcc generates optimal 8 // but it is absolutely needed to make sure gcc generates optimal
9 // code. gcc is not happy when attempting to inline too deep. 9 // code. gcc is not happy when attempting to inline too deep.
10 // 10 //
(...skipping 4603 matching lines...) Expand 10 before | Expand all | Expand 10 after
4614 STATIC_ASSERT(Code::NUMBER_OF_KINDS <= KindField::kMax + 1); 4614 STATIC_ASSERT(Code::NUMBER_OF_KINDS <= KindField::kMax + 1);
4615 WRITE_INT_FIELD(this, kFlagsOffset, flags); 4615 WRITE_INT_FIELD(this, kFlagsOffset, flags);
4616 } 4616 }
4617 4617
4618 4618
4619 Code::Kind Code::kind() { 4619 Code::Kind Code::kind() {
4620 return ExtractKindFromFlags(flags()); 4620 return ExtractKindFromFlags(flags());
4621 } 4621 }
4622 4622
4623 4623
4624 bool Code::IsCodeStubOrIC() {
4625 return kind() == STUB || kind() == HANDLER || kind() == LOAD_IC ||
4626 kind() == KEYED_LOAD_IC || kind() == CALL_IC || kind() == STORE_IC ||
4627 kind() == KEYED_STORE_IC || kind() == BINARY_OP_IC ||
4628 kind() == COMPARE_IC || kind() == COMPARE_NIL_IC ||
4629 kind() == TO_BOOLEAN_IC;
4630 }
4631
4632
4624 InlineCacheState Code::ic_state() { 4633 InlineCacheState Code::ic_state() {
4625 InlineCacheState result = ExtractICStateFromFlags(flags()); 4634 InlineCacheState result = ExtractICStateFromFlags(flags());
4626 // Only allow uninitialized or debugger states for non-IC code 4635 // Only allow uninitialized or debugger states for non-IC code
4627 // objects. This is used in the debugger to determine whether or not 4636 // objects. This is used in the debugger to determine whether or not
4628 // a call to code object has been replaced with a debug break call. 4637 // a call to code object has been replaced with a debug break call.
4629 ASSERT(is_inline_cache_stub() || 4638 ASSERT(is_inline_cache_stub() ||
4630 result == UNINITIALIZED || 4639 result == UNINITIALIZED ||
4631 result == DEBUG_STUB); 4640 result == DEBUG_STUB);
4632 return result; 4641 return result;
4633 } 4642 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
4666 } 4675 }
4667 4676
4668 4677
4669 inline void Code::set_is_crankshafted(bool value) { 4678 inline void Code::set_is_crankshafted(bool value) {
4670 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset); 4679 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset);
4671 int updated = IsCrankshaftedField::update(previous, value); 4680 int updated = IsCrankshaftedField::update(previous, value);
4672 WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated); 4681 WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated);
4673 } 4682 }
4674 4683
4675 4684
4676 int Code::major_key() {
4677 ASSERT(has_major_key());
4678 return StubMajorKeyField::decode(
4679 READ_UINT32_FIELD(this, kKindSpecificFlags2Offset));
4680 }
4681
4682
4683 void Code::set_major_key(int major) {
4684 ASSERT(has_major_key());
4685 ASSERT(0 <= major && major < 256);
4686 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset);
4687 int updated = StubMajorKeyField::update(previous, major);
4688 WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated);
4689 }
4690
4691
4692 bool Code::has_major_key() {
4693 return kind() == STUB ||
4694 kind() == HANDLER ||
4695 kind() == BINARY_OP_IC ||
4696 kind() == COMPARE_IC ||
4697 kind() == COMPARE_NIL_IC ||
4698 kind() == LOAD_IC ||
4699 kind() == KEYED_LOAD_IC ||
4700 kind() == STORE_IC ||
4701 kind() == CALL_IC ||
4702 kind() == KEYED_STORE_IC ||
4703 kind() == TO_BOOLEAN_IC;
4704 }
4705
4706
4707 bool Code::optimizable() { 4685 bool Code::optimizable() {
4708 ASSERT_EQ(FUNCTION, kind()); 4686 ASSERT_EQ(FUNCTION, kind());
4709 return READ_BYTE_FIELD(this, kOptimizableOffset) == 1; 4687 return READ_BYTE_FIELD(this, kOptimizableOffset) == 1;
4710 } 4688 }
4711 4689
4712 4690
4713 void Code::set_optimizable(bool value) { 4691 void Code::set_optimizable(bool value) {
4714 ASSERT_EQ(FUNCTION, kind()); 4692 ASSERT_EQ(FUNCTION, kind());
4715 WRITE_BYTE_FIELD(this, kOptimizableOffset, value ? 1 : 0); 4693 WRITE_BYTE_FIELD(this, kOptimizableOffset, value ? 1 : 0);
4716 } 4694 }
(...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after
6122 ACCESSORS(Code, deoptimization_data, FixedArray, kDeoptimizationDataOffset) 6100 ACCESSORS(Code, deoptimization_data, FixedArray, kDeoptimizationDataOffset)
6123 ACCESSORS(Code, raw_type_feedback_info, Object, kTypeFeedbackInfoOffset) 6101 ACCESSORS(Code, raw_type_feedback_info, Object, kTypeFeedbackInfoOffset)
6124 ACCESSORS(Code, next_code_link, Object, kNextCodeLinkOffset) 6102 ACCESSORS(Code, next_code_link, Object, kNextCodeLinkOffset)
6125 6103
6126 6104
6127 void Code::WipeOutHeader() { 6105 void Code::WipeOutHeader() {
6128 WRITE_FIELD(this, kRelocationInfoOffset, NULL); 6106 WRITE_FIELD(this, kRelocationInfoOffset, NULL);
6129 WRITE_FIELD(this, kHandlerTableOffset, NULL); 6107 WRITE_FIELD(this, kHandlerTableOffset, NULL);
6130 WRITE_FIELD(this, kDeoptimizationDataOffset, NULL); 6108 WRITE_FIELD(this, kDeoptimizationDataOffset, NULL);
6131 WRITE_FIELD(this, kConstantPoolOffset, NULL); 6109 WRITE_FIELD(this, kConstantPoolOffset, NULL);
6132 // Do not wipe out e.g. a minor key. 6110 // Do not wipe out major/minor keys on a code stub or IC
6133 if (!READ_FIELD(this, kTypeFeedbackInfoOffset)->IsSmi()) { 6111 if (!READ_FIELD(this, kTypeFeedbackInfoOffset)->IsSmi()) {
6134 WRITE_FIELD(this, kTypeFeedbackInfoOffset, NULL); 6112 WRITE_FIELD(this, kTypeFeedbackInfoOffset, NULL);
6135 } 6113 }
6136 } 6114 }
6137 6115
6138 6116
6139 Object* Code::type_feedback_info() { 6117 Object* Code::type_feedback_info() {
6140 ASSERT(kind() == FUNCTION); 6118 ASSERT(kind() == FUNCTION);
6141 return raw_type_feedback_info(); 6119 return raw_type_feedback_info();
6142 } 6120 }
6143 6121
6144 6122
6145 void Code::set_type_feedback_info(Object* value, WriteBarrierMode mode) { 6123 void Code::set_type_feedback_info(Object* value, WriteBarrierMode mode) {
6146 ASSERT(kind() == FUNCTION); 6124 ASSERT(kind() == FUNCTION);
6147 set_raw_type_feedback_info(value, mode); 6125 set_raw_type_feedback_info(value, mode);
6148 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kTypeFeedbackInfoOffset, 6126 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kTypeFeedbackInfoOffset,
6149 value, mode); 6127 value, mode);
6150 } 6128 }
6151 6129
6152 6130
6153 int Code::stub_info() { 6131 uint32_t Code::stub_key() {
6154 ASSERT(kind() == COMPARE_IC || kind() == COMPARE_NIL_IC || 6132 ASSERT(IsCodeStubOrIC());
6155 kind() == BINARY_OP_IC || kind() == LOAD_IC || kind() == CALL_IC); 6133 return Smi::cast(raw_type_feedback_info())->value() - Smi::kMinValue;
6156 return Smi::cast(raw_type_feedback_info())->value();
6157 } 6134 }
6158 6135
6159 6136
6160 void Code::set_stub_info(int value) { 6137 void Code::set_stub_key(uint32_t key) {
6161 ASSERT(kind() == COMPARE_IC || 6138 ASSERT(IsCodeStubOrIC());
6162 kind() == COMPARE_NIL_IC || 6139 set_raw_type_feedback_info(Smi::FromInt(key + Smi::kMinValue));
6163 kind() == BINARY_OP_IC ||
6164 kind() == STUB ||
6165 kind() == LOAD_IC ||
6166 kind() == CALL_IC ||
6167 kind() == KEYED_LOAD_IC ||
6168 kind() == STORE_IC ||
6169 kind() == KEYED_STORE_IC);
6170 set_raw_type_feedback_info(Smi::FromInt(value));
6171 } 6140 }
6172 6141
6173 6142
6174 ACCESSORS(Code, gc_metadata, Object, kGCMetadataOffset) 6143 ACCESSORS(Code, gc_metadata, Object, kGCMetadataOffset)
6175 INT_ACCESSORS(Code, ic_age, kICAgeOffset) 6144 INT_ACCESSORS(Code, ic_age, kICAgeOffset)
6176 6145
6177 6146
6178 byte* Code::instruction_start() { 6147 byte* Code::instruction_start() {
6179 return FIELD_ADDR(this, kHeaderSize); 6148 return FIELD_ADDR(this, kHeaderSize);
6180 } 6149 }
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after
7200 #undef READ_SHORT_FIELD 7169 #undef READ_SHORT_FIELD
7201 #undef WRITE_SHORT_FIELD 7170 #undef WRITE_SHORT_FIELD
7202 #undef READ_BYTE_FIELD 7171 #undef READ_BYTE_FIELD
7203 #undef WRITE_BYTE_FIELD 7172 #undef WRITE_BYTE_FIELD
7204 #undef NOBARRIER_READ_BYTE_FIELD 7173 #undef NOBARRIER_READ_BYTE_FIELD
7205 #undef NOBARRIER_WRITE_BYTE_FIELD 7174 #undef NOBARRIER_WRITE_BYTE_FIELD
7206 7175
7207 } } // namespace v8::internal 7176 } } // namespace v8::internal
7208 7177
7209 #endif // V8_OBJECTS_INL_H_ 7178 #endif // V8_OBJECTS_INL_H_
OLDNEW
« src/objects.h ('K') | « src/objects-debug.cc ('k') | src/stub-cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698