From 690093effea97757ecb2d104a5499579b272aa4b Mon Sep 17 00:00:00 2001 From: "mikhail.naganov@gmail.com" Date: Mon, 11 Apr 2011 11:38:34 +0000 Subject: [PATCH] Mark single-argument inline constructors as 'explicit'. There is currently a bug in cpplint.py hiding this problem. R=sgjesse@chromium.org BUG=1304 TEST=none Review URL: http://codereview.chromium.org/6820028 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7567 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- include/v8.h | 2 +- src/api.h | 6 +++--- src/heap.cc | 2 +- src/jsregexp.h | 2 +- src/mips/virtual-frame-mips.h | 2 +- src/objects-inl.h | 11 ++++++++++- src/objects.cc | 8 ++++---- src/objects.h | 11 +++++++---- src/property.h | 7 +++++++ src/scopeinfo.h | 2 +- src/x64/lithium-codegen-x64.h | 2 +- 11 files changed, 37 insertions(+), 18 deletions(-) diff --git a/include/v8.h b/include/v8.h index a990fc2e2..d15d024dc 100644 --- a/include/v8.h +++ b/include/v8.h @@ -3296,7 +3296,7 @@ class V8EXPORT Context { */ class Scope { public: - inline Scope(Handle context) : context_(context) { + explicit inline Scope(Handle context) : context_(context) { context_->Enter(); } inline ~Scope() { context_->Exit(); } diff --git a/src/api.h b/src/api.h index 6d46713ef..7423d28e2 100644 --- a/src/api.h +++ b/src/api.h @@ -53,8 +53,8 @@ class Consts { class NeanderObject { public: explicit NeanderObject(int size); - inline NeanderObject(v8::internal::Handle obj); - inline NeanderObject(v8::internal::Object* obj); + explicit inline NeanderObject(v8::internal::Handle obj); + explicit inline NeanderObject(v8::internal::Object* obj); inline v8::internal::Object* get(int index); inline void set(int index, v8::internal::Object* value); inline v8::internal::Handle value() { return value_; } @@ -69,7 +69,7 @@ class NeanderObject { class NeanderArray { public: NeanderArray(); - inline NeanderArray(v8::internal::Handle obj); + explicit inline NeanderArray(v8::internal::Handle obj); inline v8::internal::Handle value() { return obj_.value(); } diff --git a/src/heap.cc b/src/heap.cc index b2e09b40d..c77364b55 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -3231,7 +3231,7 @@ MaybeObject* Heap::AllocateGlobalObject(JSFunction* constructor) { // Fill these accessors into the dictionary. DescriptorArray* descs = map->instance_descriptors(); for (int i = 0; i < descs->number_of_descriptors(); i++) { - PropertyDetails details = descs->GetDetails(i); + PropertyDetails details(descs->GetDetails(i)); ASSERT(details.type() == CALLBACKS); // Only accessors are expected. PropertyDetails d = PropertyDetails(details.attributes(), CALLBACKS, details.index()); diff --git a/src/jsregexp.h b/src/jsregexp.h index 3ed5a7e43..b9b2f6040 100644 --- a/src/jsregexp.h +++ b/src/jsregexp.h @@ -1447,7 +1447,7 @@ class RegExpEngine: public AllStatic { class OffsetsVector { public: - inline OffsetsVector(int num_registers) + explicit inline OffsetsVector(int num_registers) : offsets_vector_length_(num_registers) { if (offsets_vector_length_ > Isolate::kJSRegexpStaticOffsetsVectorSize) { vector_ = NewArray(offsets_vector_length_); diff --git a/src/mips/virtual-frame-mips.h b/src/mips/virtual-frame-mips.h index be8b74e84..cf30b0932 100644 --- a/src/mips/virtual-frame-mips.h +++ b/src/mips/virtual-frame-mips.h @@ -106,7 +106,7 @@ class VirtualFrame : public ZoneObject { inline VirtualFrame(); // Construct an invalid virtual frame, used by JumpTargets. - inline VirtualFrame(InvalidVirtualFrameInitializer* dummy); + explicit inline VirtualFrame(InvalidVirtualFrameInitializer* dummy); // Construct a virtual frame as a clone of an existing one. explicit inline VirtualFrame(VirtualFrame* original); diff --git a/src/objects-inl.h b/src/objects-inl.h index 6ebc7ba73..ebdf0a08d 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -1774,7 +1774,7 @@ bool DescriptorArray::IsDontEnum(int descriptor_number) { void DescriptorArray::Get(int descriptor_number, Descriptor* desc) { desc->Init(GetKey(descriptor_number), GetValue(descriptor_number), - GetDetails(descriptor_number)); + PropertyDetails(GetDetails(descriptor_number))); } @@ -3939,6 +3939,15 @@ void AccessorInfo::set_property_attributes(PropertyAttributes attributes) { set_flag(Smi::FromInt(rest_value | AttributesField::encode(attributes))); } + +template +void Dictionary::SetEntry(int entry, + Object* key, + Object* value) { + SetEntry(entry, key, value, PropertyDetails(Smi::FromInt(0))); +} + + template void Dictionary::SetEntry(int entry, Object* key, diff --git a/src/objects.cc b/src/objects.cc index 05fc4890a..d211d62cf 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -2518,7 +2518,7 @@ MaybeObject* JSObject::NormalizeProperties(PropertyNormalizationMode mode, DescriptorArray* descs = map_of_this->instance_descriptors(); for (int i = 0; i < descs->number_of_descriptors(); i++) { - PropertyDetails details = descs->GetDetails(i); + PropertyDetails details(descs->GetDetails(i)); switch (details.type()) { case CONSTANT_FUNCTION: { PropertyDetails d = @@ -8101,7 +8101,7 @@ int JSObject::NumberOfLocalProperties(PropertyAttributes filter) { DescriptorArray* descs = map()->instance_descriptors(); int result = 0; for (int i = 0; i < descs->number_of_descriptors(); i++) { - PropertyDetails details = descs->GetDetails(i); + PropertyDetails details(descs->GetDetails(i)); if (details.IsProperty() && (details.attributes() & filter) == 0) { result++; } @@ -9668,7 +9668,7 @@ void NumberDictionary::RemoveNumberEntries(uint32_t from, uint32_t to) { if (key->IsNumber()) { uint32_t number = static_cast(key->Number()); if (from <= number && number < to) { - SetEntry(i, sentinel, sentinel, Smi::FromInt(0)); + SetEntry(i, sentinel, sentinel); removed_entries++; } } @@ -9688,7 +9688,7 @@ Object* Dictionary::DeleteProperty(int entry, if (details.IsDontDelete() && mode != JSObject::FORCE_DELETION) { return heap->false_value(); } - SetEntry(entry, heap->null_value(), heap->null_value(), Smi::FromInt(0)); + SetEntry(entry, heap->null_value(), heap->null_value()); HashTable::ElementRemoved(); return heap->true_value(); } diff --git a/src/objects.h b/src/objects.h index f2b5665c1..449a2109c 100644 --- a/src/objects.h +++ b/src/objects.h @@ -167,7 +167,7 @@ class PropertyDetails BASE_EMBEDDED { } // Conversion for storing details as Object*. - inline PropertyDetails(Smi* smi); + explicit inline PropertyDetails(Smi* smi); inline Smi* AsSmi(); PropertyType type() { return TypeField::decode(value_); } @@ -2569,6 +2569,9 @@ class Dictionary: public HashTable { Object* SlowReverseLookup(Object* value); // Sets the entry to (key, value) pair. + inline void SetEntry(int entry, + Object* key, + Object* value); inline void SetEntry(int entry, Object* key, Object* value, @@ -5147,7 +5150,7 @@ enum RobustnessFlag {ROBUST_STRING_TRAVERSAL, FAST_STRING_TRAVERSAL}; class StringHasher { public: - inline StringHasher(int length); + explicit inline StringHasher(int length); // Returns true if the hash of this string can be computed without // looking at the contents. @@ -5894,7 +5897,7 @@ class StringInputBuffer: public unibrow::InputBuffer { public: virtual void Seek(unsigned pos); inline StringInputBuffer(): unibrow::InputBuffer() {} - inline StringInputBuffer(String* backing): + explicit inline StringInputBuffer(String* backing): unibrow::InputBuffer(backing) {} }; @@ -5905,7 +5908,7 @@ class SafeStringInputBuffer virtual void Seek(unsigned pos); inline SafeStringInputBuffer() : unibrow::InputBuffer() {} - inline SafeStringInputBuffer(String** backing) + explicit inline SafeStringInputBuffer(String** backing) : unibrow::InputBuffer(backing) {} }; diff --git a/src/property.h b/src/property.h index fa3916eb1..ee95ca217 100644 --- a/src/property.h +++ b/src/property.h @@ -185,6 +185,13 @@ class LookupResult BASE_EMBEDDED { number_ = number; } + void DescriptorResult(JSObject* holder, Smi* details, int number) { + lookup_type_ = DESCRIPTOR_TYPE; + holder_ = holder; + details_ = PropertyDetails(details); + number_ = number; + } + void ConstantResult(JSObject* holder) { lookup_type_ = CONSTANT_TYPE; holder_ = holder; diff --git a/src/scopeinfo.h b/src/scopeinfo.h index cc9f8165a..2552af22f 100644 --- a/src/scopeinfo.h +++ b/src/scopeinfo.h @@ -220,7 +220,7 @@ class ContextSlotCache { ASSERT(index == this->index()); } - inline Value(uint32_t value) : value_(value) {} + explicit inline Value(uint32_t value) : value_(value) {} uint32_t raw() { return value_; } diff --git a/src/x64/lithium-codegen-x64.h b/src/x64/lithium-codegen-x64.h index d82379595..34277f6ed 100644 --- a/src/x64/lithium-codegen-x64.h +++ b/src/x64/lithium-codegen-x64.h @@ -272,7 +272,7 @@ class LCodeGen BASE_EMBEDDED { void EmitPushConstantOperand(LOperand* operand); struct JumpTableEntry { - inline JumpTableEntry(Address entry) + explicit inline JumpTableEntry(Address entry) : label(), address(entry) { } Label label; -- 2.34.1