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

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

Issue 2587373002: Revert of [runtime] Add fast-paths for common conversion methods (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « src/objects.cc ('k') | src/regexp/regexp-utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 } 1095 }
1096 1096
1097 1097
1098 // static 1098 // static
1099 MaybeHandle<Name> Object::ToName(Isolate* isolate, Handle<Object> input) { 1099 MaybeHandle<Name> Object::ToName(Isolate* isolate, Handle<Object> input) {
1100 if (input->IsName()) return Handle<Name>::cast(input); 1100 if (input->IsName()) return Handle<Name>::cast(input);
1101 return ConvertToName(isolate, input); 1101 return ConvertToName(isolate, input);
1102 } 1102 }
1103 1103
1104 // static 1104 // static
1105 MaybeHandle<Object> Object::ToPropertyKey(Isolate* isolate,
1106 Handle<Object> value) {
1107 if (value->IsSmi() || HeapObject::cast(*value)->IsName()) return value;
1108 return ConvertToPropertyKey(isolate, value);
1109 }
1110
1111 // static
1112 MaybeHandle<Object> Object::ToPrimitive(Handle<Object> input, 1105 MaybeHandle<Object> Object::ToPrimitive(Handle<Object> input,
1113 ToPrimitiveHint hint) { 1106 ToPrimitiveHint hint) {
1114 if (input->IsPrimitive()) return input; 1107 if (input->IsPrimitive()) return input;
1115 return JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(input), hint); 1108 return JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(input), hint);
1116 } 1109 }
1117 1110
1118 // static 1111 // static
1119 MaybeHandle<Object> Object::ToNumber(Handle<Object> input) { 1112 MaybeHandle<Object> Object::ToNumber(Handle<Object> input) {
1120 if (input->IsNumber()) return input; 1113 if (input->IsNumber()) return input;
1121 return ConvertToNumber(HeapObject::cast(*input)->GetIsolate(), input); 1114 return ConvertToNumber(HeapObject::cast(*input)->GetIsolate(), input);
(...skipping 16 matching lines...) Expand all
1138 if (input->IsSmi()) return handle(Smi::cast(*input)->ToUint32Smi(), isolate); 1131 if (input->IsSmi()) return handle(Smi::cast(*input)->ToUint32Smi(), isolate);
1139 return ConvertToUint32(isolate, input); 1132 return ConvertToUint32(isolate, input);
1140 } 1133 }
1141 1134
1142 // static 1135 // static
1143 MaybeHandle<String> Object::ToString(Isolate* isolate, Handle<Object> input) { 1136 MaybeHandle<String> Object::ToString(Isolate* isolate, Handle<Object> input) {
1144 if (input->IsString()) return Handle<String>::cast(input); 1137 if (input->IsString()) return Handle<String>::cast(input);
1145 return ConvertToString(isolate, input); 1138 return ConvertToString(isolate, input);
1146 } 1139 }
1147 1140
1148 // static
1149 MaybeHandle<Object> Object::ToLength(Isolate* isolate, Handle<Object> input) {
1150 if (input->IsSmi()) {
1151 int value = std::max(Smi::cast(*input)->value(), 0);
1152 return handle(Smi::FromInt(value), isolate);
1153 }
1154 return ConvertToLength(isolate, input);
1155 }
1156
1157 // static
1158 MaybeHandle<Object> Object::ToIndex(Isolate* isolate, Handle<Object> input,
1159 MessageTemplate::Template error_index) {
1160 if (input->IsSmi() && Smi::cast(*input)->value() >= 0) return input;
1161 return ConvertToIndex(isolate, input, error_index);
1162 }
1163
1164 bool Object::HasSpecificClassOf(String* name) { 1141 bool Object::HasSpecificClassOf(String* name) {
1165 return this->IsJSObject() && (JSObject::cast(this)->class_name() == name); 1142 return this->IsJSObject() && (JSObject::cast(this)->class_name() == name);
1166 } 1143 }
1167 1144
1168 MaybeHandle<Object> Object::GetProperty(Handle<Object> object, 1145 MaybeHandle<Object> Object::GetProperty(Handle<Object> object,
1169 Handle<Name> name) { 1146 Handle<Name> name) {
1170 LookupIterator it(object, name); 1147 LookupIterator it(object, name);
1171 if (!it.IsFound()) return it.factory()->undefined_value(); 1148 if (!it.IsFound()) return it.factory()->undefined_value();
1172 return GetProperty(&it); 1149 return GetProperty(&it);
1173 } 1150 }
(...skipping 7280 matching lines...) Expand 10 before | Expand all | Expand 10 after
8454 #undef WRITE_INT64_FIELD 8431 #undef WRITE_INT64_FIELD
8455 #undef READ_BYTE_FIELD 8432 #undef READ_BYTE_FIELD
8456 #undef WRITE_BYTE_FIELD 8433 #undef WRITE_BYTE_FIELD
8457 #undef NOBARRIER_READ_BYTE_FIELD 8434 #undef NOBARRIER_READ_BYTE_FIELD
8458 #undef NOBARRIER_WRITE_BYTE_FIELD 8435 #undef NOBARRIER_WRITE_BYTE_FIELD
8459 8436
8460 } // namespace internal 8437 } // namespace internal
8461 } // namespace v8 8438 } // namespace v8
8462 8439
8463 #endif // V8_OBJECTS_INL_H_ 8440 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/regexp/regexp-utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698