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

Side by Side Diff: src/objects.cc

Issue 2692933002: Revert of Remove SIMD.js from V8. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « src/objects.h ('k') | src/objects-body-descriptors-inl.h » ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <memory> 9 #include <memory>
10 #include <sstream> 10 #include <sstream>
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 if (input->IsString()) { 151 if (input->IsString()) {
152 return String::ToNumber(Handle<String>::cast(input)); 152 return String::ToNumber(Handle<String>::cast(input));
153 } 153 }
154 if (input->IsOddball()) { 154 if (input->IsOddball()) {
155 return Oddball::ToNumber(Handle<Oddball>::cast(input)); 155 return Oddball::ToNumber(Handle<Oddball>::cast(input));
156 } 156 }
157 if (input->IsSymbol()) { 157 if (input->IsSymbol()) {
158 THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kSymbolToNumber), 158 THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kSymbolToNumber),
159 Object); 159 Object);
160 } 160 }
161 if (input->IsSimd128Value()) {
162 THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kSimdToNumber),
163 Object);
164 }
161 ASSIGN_RETURN_ON_EXCEPTION( 165 ASSIGN_RETURN_ON_EXCEPTION(
162 isolate, input, JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(input), 166 isolate, input, JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(input),
163 ToPrimitiveHint::kNumber), 167 ToPrimitiveHint::kNumber),
164 Object); 168 Object);
165 } 169 }
166 } 170 }
167 171
168 // static 172 // static
169 MaybeHandle<Object> Object::ConvertToInteger(Isolate* isolate, 173 MaybeHandle<Object> Object::ConvertToInteger(Isolate* isolate,
170 Handle<Object> input) { 174 Handle<Object> input) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 if (input->IsOddball()) { 238 if (input->IsOddball()) {
235 return handle(Handle<Oddball>::cast(input)->to_string(), isolate); 239 return handle(Handle<Oddball>::cast(input)->to_string(), isolate);
236 } 240 }
237 if (input->IsNumber()) { 241 if (input->IsNumber()) {
238 return isolate->factory()->NumberToString(input); 242 return isolate->factory()->NumberToString(input);
239 } 243 }
240 if (input->IsSymbol()) { 244 if (input->IsSymbol()) {
241 THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kSymbolToString), 245 THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kSymbolToString),
242 String); 246 String);
243 } 247 }
248 if (input->IsSimd128Value()) {
249 return Simd128Value::ToString(Handle<Simd128Value>::cast(input));
250 }
244 ASSIGN_RETURN_ON_EXCEPTION( 251 ASSIGN_RETURN_ON_EXCEPTION(
245 isolate, input, JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(input), 252 isolate, input, JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(input),
246 ToPrimitiveHint::kString), 253 ToPrimitiveHint::kString),
247 String); 254 String);
248 // The previous isString() check happened in Object::ToString and thus we 255 // The previous isString() check happened in Object::ToString and thus we
249 // put it at the end of the loop in this helper. 256 // put it at the end of the loop in this helper.
250 if (input->IsString()) { 257 if (input->IsString()) {
251 return Handle<String>::cast(input); 258 return Handle<String>::cast(input);
252 } 259 }
253 } 260 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 return builder.Finish().ToHandleChecked(); 297 return builder.Finish().ToHandleChecked();
291 } 298 }
292 299
293 } // namespace 300 } // namespace
294 301
295 // static 302 // static
296 Handle<String> Object::NoSideEffectsToString(Isolate* isolate, 303 Handle<String> Object::NoSideEffectsToString(Isolate* isolate,
297 Handle<Object> input) { 304 Handle<Object> input) {
298 DisallowJavascriptExecution no_js(isolate); 305 DisallowJavascriptExecution no_js(isolate);
299 306
300 if (input->IsString() || input->IsNumber() || input->IsOddball()) { 307 if (input->IsString() || input->IsNumber() || input->IsOddball() ||
308 input->IsSimd128Value()) {
301 return Object::ToString(isolate, input).ToHandleChecked(); 309 return Object::ToString(isolate, input).ToHandleChecked();
302 } else if (input->IsFunction()) { 310 } else if (input->IsFunction()) {
303 // -- F u n c t i o n 311 // -- F u n c t i o n
304 Handle<String> fun_str; 312 Handle<String> fun_str;
305 if (input->IsJSBoundFunction()) { 313 if (input->IsJSBoundFunction()) {
306 fun_str = JSBoundFunction::ToString(Handle<JSBoundFunction>::cast(input)); 314 fun_str = JSBoundFunction::ToString(Handle<JSBoundFunction>::cast(input));
307 } else { 315 } else {
308 DCHECK(input->IsJSFunction()); 316 DCHECK(input->IsJSFunction());
309 fun_str = JSFunction::ToString(Handle<JSFunction>::cast(input)); 317 fun_str = JSFunction::ToString(Handle<JSFunction>::cast(input));
310 } 318 }
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 if (y->IsSymbol()) { 573 if (y->IsSymbol()) {
566 return Just(x.is_identical_to(y)); 574 return Just(x.is_identical_to(y));
567 } else if (y->IsJSReceiver()) { 575 } else if (y->IsJSReceiver()) {
568 if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y)) 576 if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y))
569 .ToHandle(&y)) { 577 .ToHandle(&y)) {
570 return Nothing<bool>(); 578 return Nothing<bool>();
571 } 579 }
572 } else { 580 } else {
573 return Just(false); 581 return Just(false);
574 } 582 }
583 } else if (x->IsSimd128Value()) {
584 if (y->IsSimd128Value()) {
585 return Just(Simd128Value::Equals(Handle<Simd128Value>::cast(x),
586 Handle<Simd128Value>::cast(y)));
587 } else if (y->IsJSReceiver()) {
588 if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y))
589 .ToHandle(&y)) {
590 return Nothing<bool>();
591 }
592 } else {
593 return Just(false);
594 }
575 } else if (x->IsJSReceiver()) { 595 } else if (x->IsJSReceiver()) {
576 if (y->IsJSReceiver()) { 596 if (y->IsJSReceiver()) {
577 return Just(x.is_identical_to(y)); 597 return Just(x.is_identical_to(y));
578 } else if (y->IsUndetectable()) { 598 } else if (y->IsUndetectable()) {
579 return Just(x->IsUndetectable()); 599 return Just(x->IsUndetectable());
580 } else if (y->IsBoolean()) { 600 } else if (y->IsBoolean()) {
581 y = Oddball::ToNumber(Handle<Oddball>::cast(y)); 601 y = Oddball::ToNumber(Handle<Oddball>::cast(y));
582 } else if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(x)) 602 } else if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(x))
583 .ToHandle(&x)) { 603 .ToHandle(&x)) {
584 return Nothing<bool>(); 604 return Nothing<bool>();
585 } 605 }
586 } else { 606 } else {
587 return Just(x->IsUndetectable() && y->IsUndetectable()); 607 return Just(x->IsUndetectable() && y->IsUndetectable());
588 } 608 }
589 } 609 }
590 } 610 }
591 611
592 612
593 bool Object::StrictEquals(Object* that) { 613 bool Object::StrictEquals(Object* that) {
594 if (this->IsNumber()) { 614 if (this->IsNumber()) {
595 if (!that->IsNumber()) return false; 615 if (!that->IsNumber()) return false;
596 return NumberEquals(this, that); 616 return NumberEquals(this, that);
597 } else if (this->IsString()) { 617 } else if (this->IsString()) {
598 if (!that->IsString()) return false; 618 if (!that->IsString()) return false;
599 return String::cast(this)->Equals(String::cast(that)); 619 return String::cast(this)->Equals(String::cast(that));
620 } else if (this->IsSimd128Value()) {
621 if (!that->IsSimd128Value()) return false;
622 return Simd128Value::cast(this)->Equals(Simd128Value::cast(that));
600 } 623 }
601 return this == that; 624 return this == that;
602 } 625 }
603 626
604 627
605 // static 628 // static
606 Handle<String> Object::TypeOf(Isolate* isolate, Handle<Object> object) { 629 Handle<String> Object::TypeOf(Isolate* isolate, Handle<Object> object) {
607 if (object->IsNumber()) return isolate->factory()->number_string(); 630 if (object->IsNumber()) return isolate->factory()->number_string();
608 if (object->IsOddball()) return handle(Oddball::cast(*object)->type_of()); 631 if (object->IsOddball()) return handle(Oddball::cast(*object)->type_of());
609 if (object->IsUndetectable()) { 632 if (object->IsUndetectable()) {
610 return isolate->factory()->undefined_string(); 633 return isolate->factory()->undefined_string();
611 } 634 }
612 if (object->IsString()) return isolate->factory()->string_string(); 635 if (object->IsString()) return isolate->factory()->string_string();
613 if (object->IsSymbol()) return isolate->factory()->symbol_string(); 636 if (object->IsSymbol()) return isolate->factory()->symbol_string();
614 if (object->IsString()) return isolate->factory()->string_string(); 637 if (object->IsString()) return isolate->factory()->string_string();
638 #define SIMD128_TYPE(TYPE, Type, type, lane_count, lane_type) \
639 if (object->Is##Type()) return isolate->factory()->type##_string();
640 SIMD128_TYPES(SIMD128_TYPE)
641 #undef SIMD128_TYPE
615 if (object->IsCallable()) return isolate->factory()->function_string(); 642 if (object->IsCallable()) return isolate->factory()->function_string();
616 return isolate->factory()->object_string(); 643 return isolate->factory()->object_string();
617 } 644 }
618 645
619 646
620 // static 647 // static
621 MaybeHandle<Object> Object::Multiply(Isolate* isolate, Handle<Object> lhs, 648 MaybeHandle<Object> Object::Multiply(Isolate* isolate, Handle<Object> lhs,
622 Handle<Object> rhs) { 649 Handle<Object> rhs) {
623 if (!lhs->IsNumber() || !rhs->IsNumber()) { 650 if (!lhs->IsNumber() || !rhs->IsNumber()) {
624 ASSIGN_RETURN_ON_EXCEPTION(isolate, lhs, Object::ToNumber(lhs), Object); 651 ASSIGN_RETURN_ON_EXCEPTION(isolate, lhs, Object::ToNumber(lhs), Object);
(...skipping 1522 matching lines...) Expand 10 before | Expand all | Expand 10 after
2147 return Just(true); 2174 return Just(true);
2148 } 2175 }
2149 2176
2150 Map* Object::GetPrototypeChainRootMap(Isolate* isolate) { 2177 Map* Object::GetPrototypeChainRootMap(Isolate* isolate) {
2151 DisallowHeapAllocation no_alloc; 2178 DisallowHeapAllocation no_alloc;
2152 if (IsSmi()) { 2179 if (IsSmi()) {
2153 Context* native_context = isolate->context()->native_context(); 2180 Context* native_context = isolate->context()->native_context();
2154 return native_context->number_function()->initial_map(); 2181 return native_context->number_function()->initial_map();
2155 } 2182 }
2156 2183
2157 // The object is either a number, a string, a symbol, a boolean, a real JS 2184 // The object is either a number, a string, a symbol, a boolean, a SIMD value,
2158 // object, or a Harmony proxy. 2185 // a real JS object, or a Harmony proxy.
2159 HeapObject* heap_object = HeapObject::cast(this); 2186 HeapObject* heap_object = HeapObject::cast(this);
2160 return heap_object->map()->GetPrototypeChainRootMap(isolate); 2187 return heap_object->map()->GetPrototypeChainRootMap(isolate);
2161 } 2188 }
2162 2189
2163 Map* Map::GetPrototypeChainRootMap(Isolate* isolate) { 2190 Map* Map::GetPrototypeChainRootMap(Isolate* isolate) {
2164 DisallowHeapAllocation no_alloc; 2191 DisallowHeapAllocation no_alloc;
2165 if (IsJSReceiverMap()) { 2192 if (IsJSReceiverMap()) {
2166 return this; 2193 return this;
2167 } 2194 }
2168 int constructor_function_index = GetConstructorFunctionIndex(); 2195 int constructor_function_index = GetConstructorFunctionIndex();
2169 if (constructor_function_index != Map::kNoConstructorFunctionIndex) { 2196 if (constructor_function_index != Map::kNoConstructorFunctionIndex) {
2170 Context* native_context = isolate->context()->native_context(); 2197 Context* native_context = isolate->context()->native_context();
2171 JSFunction* constructor_function = 2198 JSFunction* constructor_function =
2172 JSFunction::cast(native_context->get(constructor_function_index)); 2199 JSFunction::cast(native_context->get(constructor_function_index));
2173 return constructor_function->initial_map(); 2200 return constructor_function->initial_map();
2174 } 2201 }
2175 return isolate->heap()->null_value()->map(); 2202 return isolate->heap()->null_value()->map();
2176 } 2203 }
2177 2204
2178 namespace { 2205 namespace {
2179 2206
2180 // Returns a non-SMI for JSObjects, but returns the hash code for simple 2207 // Returns a non-SMI for JSObjects, but returns the hash code for simple
2181 // objects. This avoids a double lookup in the cases where we know we will 2208 // objects. This avoids a double lookup in the cases where we know we will
2182 // add the hash to the JSObject if it does not already exist. 2209 // add the hash to the JSObject if it does not already exist.
2183 Object* GetSimpleHash(Object* object) { 2210 Object* GetSimpleHash(Object* object) {
2184 // The object is either a Smi, a HeapNumber, a name, an odd-ball, a real JS 2211 // The object is either a Smi, a HeapNumber, a name, an odd-ball,
2185 // object, or a Harmony proxy. 2212 // a SIMD value type, a real JS object, or a Harmony proxy.
2186 if (object->IsSmi()) { 2213 if (object->IsSmi()) {
2187 uint32_t hash = 2214 uint32_t hash =
2188 ComputeIntegerHash(Smi::cast(object)->value(), kZeroHashSeed); 2215 ComputeIntegerHash(Smi::cast(object)->value(), kZeroHashSeed);
2189 return Smi::FromInt(hash & Smi::kMaxValue); 2216 return Smi::FromInt(hash & Smi::kMaxValue);
2190 } 2217 }
2191 if (object->IsHeapNumber()) { 2218 if (object->IsHeapNumber()) {
2192 double num = HeapNumber::cast(object)->value(); 2219 double num = HeapNumber::cast(object)->value();
2193 if (std::isnan(num)) return Smi::FromInt(Smi::kMaxValue); 2220 if (std::isnan(num)) return Smi::FromInt(Smi::kMaxValue);
2194 if (i::IsMinusZero(num)) num = 0; 2221 if (i::IsMinusZero(num)) num = 0;
2195 if (IsSmiDouble(num)) { 2222 if (IsSmiDouble(num)) {
2196 return Smi::FromInt(FastD2I(num))->GetHash(); 2223 return Smi::FromInt(FastD2I(num))->GetHash();
2197 } 2224 }
2198 uint32_t hash = ComputeLongHash(double_to_uint64(num)); 2225 uint32_t hash = ComputeLongHash(double_to_uint64(num));
2199 return Smi::FromInt(hash & Smi::kMaxValue); 2226 return Smi::FromInt(hash & Smi::kMaxValue);
2200 } 2227 }
2201 if (object->IsName()) { 2228 if (object->IsName()) {
2202 uint32_t hash = Name::cast(object)->Hash(); 2229 uint32_t hash = Name::cast(object)->Hash();
2203 return Smi::FromInt(hash); 2230 return Smi::FromInt(hash);
2204 } 2231 }
2205 if (object->IsOddball()) { 2232 if (object->IsOddball()) {
2206 uint32_t hash = Oddball::cast(object)->to_string()->Hash(); 2233 uint32_t hash = Oddball::cast(object)->to_string()->Hash();
2207 return Smi::FromInt(hash); 2234 return Smi::FromInt(hash);
2208 } 2235 }
2236 if (object->IsSimd128Value()) {
2237 uint32_t hash = Simd128Value::cast(object)->Hash();
2238 return Smi::FromInt(hash & Smi::kMaxValue);
2239 }
2209 DCHECK(object->IsJSReceiver()); 2240 DCHECK(object->IsJSReceiver());
2210 // Simply return the receiver as it is guaranteed to not be a SMI. 2241 // Simply return the receiver as it is guaranteed to not be a SMI.
2211 return object; 2242 return object;
2212 } 2243 }
2213 2244
2214 } // namespace 2245 } // namespace
2215 2246
2216 Object* Object::GetHash() { 2247 Object* Object::GetHash() {
2217 Object* hash = GetSimpleHash(this); 2248 Object* hash = GetSimpleHash(this);
2218 if (hash->IsSmi()) return hash; 2249 if (hash->IsSmi()) return hash;
(...skipping 26 matching lines...) Expand all
2245 // SameValue(NaN, NaN) is true. 2276 // SameValue(NaN, NaN) is true.
2246 if (this_value != other_value) { 2277 if (this_value != other_value) {
2247 return std::isnan(this_value) && std::isnan(other_value); 2278 return std::isnan(this_value) && std::isnan(other_value);
2248 } 2279 }
2249 // SameValue(0.0, -0.0) is false. 2280 // SameValue(0.0, -0.0) is false.
2250 return (std::signbit(this_value) == std::signbit(other_value)); 2281 return (std::signbit(this_value) == std::signbit(other_value));
2251 } 2282 }
2252 if (IsString() && other->IsString()) { 2283 if (IsString() && other->IsString()) {
2253 return String::cast(this)->Equals(String::cast(other)); 2284 return String::cast(this)->Equals(String::cast(other));
2254 } 2285 }
2286 if (IsFloat32x4() && other->IsFloat32x4()) {
2287 Float32x4* a = Float32x4::cast(this);
2288 Float32x4* b = Float32x4::cast(other);
2289 for (int i = 0; i < 4; i++) {
2290 float x = a->get_lane(i);
2291 float y = b->get_lane(i);
2292 // Implements the ES5 SameValue operation for floating point types.
2293 // http://www.ecma-international.org/ecma-262/6.0/#sec-samevalue
2294 if (x != y && !(std::isnan(x) && std::isnan(y))) return false;
2295 if (std::signbit(x) != std::signbit(y)) return false;
2296 }
2297 return true;
2298 } else if (IsSimd128Value() && other->IsSimd128Value()) {
2299 Simd128Value* a = Simd128Value::cast(this);
2300 Simd128Value* b = Simd128Value::cast(other);
2301 return a->map() == b->map() && a->BitwiseEquals(b);
2302 }
2255 return false; 2303 return false;
2256 } 2304 }
2257 2305
2258 2306
2259 bool Object::SameValueZero(Object* other) { 2307 bool Object::SameValueZero(Object* other) {
2260 if (other == this) return true; 2308 if (other == this) return true;
2261 2309
2262 // The object is either a number, a name, an odd-ball, 2310 // The object is either a number, a name, an odd-ball,
2263 // a real JS object, or a Harmony proxy. 2311 // a real JS object, or a Harmony proxy.
2264 if (IsNumber() && other->IsNumber()) { 2312 if (IsNumber() && other->IsNumber()) {
2265 double this_value = Number(); 2313 double this_value = Number();
2266 double other_value = other->Number(); 2314 double other_value = other->Number();
2267 // +0 == -0 is true 2315 // +0 == -0 is true
2268 return this_value == other_value || 2316 return this_value == other_value ||
2269 (std::isnan(this_value) && std::isnan(other_value)); 2317 (std::isnan(this_value) && std::isnan(other_value));
2270 } 2318 }
2271 if (IsString() && other->IsString()) { 2319 if (IsString() && other->IsString()) {
2272 return String::cast(this)->Equals(String::cast(other)); 2320 return String::cast(this)->Equals(String::cast(other));
2273 } 2321 }
2322 if (IsFloat32x4() && other->IsFloat32x4()) {
2323 Float32x4* a = Float32x4::cast(this);
2324 Float32x4* b = Float32x4::cast(other);
2325 for (int i = 0; i < 4; i++) {
2326 float x = a->get_lane(i);
2327 float y = b->get_lane(i);
2328 // Implements the ES6 SameValueZero operation for floating point types.
2329 // http://www.ecma-international.org/ecma-262/6.0/#sec-samevaluezero
2330 if (x != y && !(std::isnan(x) && std::isnan(y))) return false;
2331 // SameValueZero doesn't distinguish between 0 and -0.
2332 }
2333 return true;
2334 } else if (IsSimd128Value() && other->IsSimd128Value()) {
2335 Simd128Value* a = Simd128Value::cast(this);
2336 Simd128Value* b = Simd128Value::cast(other);
2337 return a->map() == b->map() && a->BitwiseEquals(b);
2338 }
2274 return false; 2339 return false;
2275 } 2340 }
2276 2341
2277 2342
2278 MaybeHandle<Object> Object::ArraySpeciesConstructor( 2343 MaybeHandle<Object> Object::ArraySpeciesConstructor(
2279 Isolate* isolate, Handle<Object> original_array) { 2344 Isolate* isolate, Handle<Object> original_array) {
2280 Handle<Object> default_species = isolate->array_function(); 2345 Handle<Object> default_species = isolate->array_function();
2281 if (original_array->IsJSArray() && 2346 if (original_array->IsJSArray() &&
2282 Handle<JSArray>::cast(original_array)->HasArrayPrototype(isolate) && 2347 Handle<JSArray>::cast(original_array)->HasArrayPrototype(isolate) &&
2283 isolate->IsArraySpeciesLookupChainIntact()) { 2348 isolate->IsArraySpeciesLookupChainIntact()) {
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
3005 HeapNumber::cast(this)->HeapNumberPrint(os); 3070 HeapNumber::cast(this)->HeapNumberPrint(os);
3006 os << ">"; 3071 os << ">";
3007 break; 3072 break;
3008 } 3073 }
3009 case MUTABLE_HEAP_NUMBER_TYPE: { 3074 case MUTABLE_HEAP_NUMBER_TYPE: {
3010 os << "<MutableNumber: "; 3075 os << "<MutableNumber: ";
3011 HeapNumber::cast(this)->HeapNumberPrint(os); 3076 HeapNumber::cast(this)->HeapNumberPrint(os);
3012 os << '>'; 3077 os << '>';
3013 break; 3078 break;
3014 } 3079 }
3080 case SIMD128_VALUE_TYPE: {
3081 #define SIMD128_TYPE(TYPE, Type, type, lane_count, lane_type) \
3082 if (Is##Type()) { \
3083 os << "<" #Type ">"; \
3084 break; \
3085 }
3086 SIMD128_TYPES(SIMD128_TYPE)
3087 #undef SIMD128_TYPE
3088 UNREACHABLE();
3089 break;
3090 }
3015 case JS_PROXY_TYPE: 3091 case JS_PROXY_TYPE:
3016 os << "<JSProxy>"; 3092 os << "<JSProxy>";
3017 break; 3093 break;
3018 case FOREIGN_TYPE: 3094 case FOREIGN_TYPE:
3019 os << "<Foreign>"; 3095 os << "<Foreign>";
3020 break; 3096 break;
3021 case CELL_TYPE: { 3097 case CELL_TYPE: {
3022 os << "Cell for "; 3098 os << "Cell for ";
3023 HeapStringAllocator allocator; 3099 HeapStringAllocator allocator;
3024 StringStream accumulator(&allocator); 3100 StringStream accumulator(&allocator);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
3095 3171
3096 #define READ_INT32_FIELD(p, offset) \ 3172 #define READ_INT32_FIELD(p, offset) \
3097 (*reinterpret_cast<const int32_t*>(FIELD_ADDR_CONST(p, offset))) 3173 (*reinterpret_cast<const int32_t*>(FIELD_ADDR_CONST(p, offset)))
3098 3174
3099 #define READ_INT64_FIELD(p, offset) \ 3175 #define READ_INT64_FIELD(p, offset) \
3100 (*reinterpret_cast<const int64_t*>(FIELD_ADDR_CONST(p, offset))) 3176 (*reinterpret_cast<const int64_t*>(FIELD_ADDR_CONST(p, offset)))
3101 3177
3102 #define READ_BYTE_FIELD(p, offset) \ 3178 #define READ_BYTE_FIELD(p, offset) \
3103 (*reinterpret_cast<const byte*>(FIELD_ADDR_CONST(p, offset))) 3179 (*reinterpret_cast<const byte*>(FIELD_ADDR_CONST(p, offset)))
3104 3180
3181
3182 // static
3183 Handle<String> Simd128Value::ToString(Handle<Simd128Value> input) {
3184 #define SIMD128_TYPE(TYPE, Type, type, lane_count, lane_type) \
3185 if (input->Is##Type()) return Type::ToString(Handle<Type>::cast(input));
3186 SIMD128_TYPES(SIMD128_TYPE)
3187 #undef SIMD128_TYPE
3188 UNREACHABLE();
3189 return Handle<String>::null();
3190 }
3191
3192
3193 // static
3194 Handle<String> Float32x4::ToString(Handle<Float32x4> input) {
3195 Isolate* const isolate = input->GetIsolate();
3196 char arr[100];
3197 Vector<char> buffer(arr, arraysize(arr));
3198 std::ostringstream os;
3199 os << "SIMD.Float32x4("
3200 << std::string(DoubleToCString(input->get_lane(0), buffer)) << ", "
3201 << std::string(DoubleToCString(input->get_lane(1), buffer)) << ", "
3202 << std::string(DoubleToCString(input->get_lane(2), buffer)) << ", "
3203 << std::string(DoubleToCString(input->get_lane(3), buffer)) << ")";
3204 return isolate->factory()->NewStringFromAsciiChecked(os.str().c_str());
3205 }
3206
3207
3208 #define SIMD128_BOOL_TO_STRING(Type, lane_count) \
3209 Handle<String> Type::ToString(Handle<Type> input) { \
3210 Isolate* const isolate = input->GetIsolate(); \
3211 std::ostringstream os; \
3212 os << "SIMD." #Type "("; \
3213 os << (input->get_lane(0) ? "true" : "false"); \
3214 for (int i = 1; i < lane_count; i++) { \
3215 os << ", " << (input->get_lane(i) ? "true" : "false"); \
3216 } \
3217 os << ")"; \
3218 return isolate->factory()->NewStringFromAsciiChecked(os.str().c_str()); \
3219 }
3220 SIMD128_BOOL_TO_STRING(Bool32x4, 4)
3221 SIMD128_BOOL_TO_STRING(Bool16x8, 8)
3222 SIMD128_BOOL_TO_STRING(Bool8x16, 16)
3223 #undef SIMD128_BOOL_TO_STRING
3224
3225
3226 #define SIMD128_INT_TO_STRING(Type, lane_count) \
3227 Handle<String> Type::ToString(Handle<Type> input) { \
3228 Isolate* const isolate = input->GetIsolate(); \
3229 char arr[100]; \
3230 Vector<char> buffer(arr, arraysize(arr)); \
3231 std::ostringstream os; \
3232 os << "SIMD." #Type "("; \
3233 os << IntToCString(input->get_lane(0), buffer); \
3234 for (int i = 1; i < lane_count; i++) { \
3235 os << ", " << IntToCString(input->get_lane(i), buffer); \
3236 } \
3237 os << ")"; \
3238 return isolate->factory()->NewStringFromAsciiChecked(os.str().c_str()); \
3239 }
3240 SIMD128_INT_TO_STRING(Int32x4, 4)
3241 SIMD128_INT_TO_STRING(Uint32x4, 4)
3242 SIMD128_INT_TO_STRING(Int16x8, 8)
3243 SIMD128_INT_TO_STRING(Uint16x8, 8)
3244 SIMD128_INT_TO_STRING(Int8x16, 16)
3245 SIMD128_INT_TO_STRING(Uint8x16, 16)
3246 #undef SIMD128_INT_TO_STRING
3247
3248
3249 bool Simd128Value::BitwiseEquals(const Simd128Value* other) const {
3250 return READ_INT64_FIELD(this, kValueOffset) ==
3251 READ_INT64_FIELD(other, kValueOffset) &&
3252 READ_INT64_FIELD(this, kValueOffset + kInt64Size) ==
3253 READ_INT64_FIELD(other, kValueOffset + kInt64Size);
3254 }
3255
3256
3257 uint32_t Simd128Value::Hash() const {
3258 uint32_t seed = v8::internal::kZeroHashSeed;
3259 uint32_t hash;
3260 hash = ComputeIntegerHash(READ_INT32_FIELD(this, kValueOffset), seed);
3261 hash = ComputeIntegerHash(
3262 READ_INT32_FIELD(this, kValueOffset + 1 * kInt32Size), hash * 31);
3263 hash = ComputeIntegerHash(
3264 READ_INT32_FIELD(this, kValueOffset + 2 * kInt32Size), hash * 31);
3265 hash = ComputeIntegerHash(
3266 READ_INT32_FIELD(this, kValueOffset + 3 * kInt32Size), hash * 31);
3267 return hash;
3268 }
3269
3270
3271 void Simd128Value::CopyBits(void* destination) const {
3272 memcpy(destination, &READ_BYTE_FIELD(this, kValueOffset), kSimd128Size);
3273 }
3274
3275
3105 String* JSReceiver::class_name() { 3276 String* JSReceiver::class_name() {
3106 if (IsFunction()) { 3277 if (IsFunction()) {
3107 return GetHeap()->Function_string(); 3278 return GetHeap()->Function_string();
3108 } 3279 }
3109 Object* maybe_constructor = map()->GetConstructor(); 3280 Object* maybe_constructor = map()->GetConstructor();
3110 if (maybe_constructor->IsJSFunction()) { 3281 if (maybe_constructor->IsJSFunction()) {
3111 JSFunction* constructor = JSFunction::cast(maybe_constructor); 3282 JSFunction* constructor = JSFunction::cast(maybe_constructor);
3112 return String::cast(constructor->shared()->instance_class_name()); 3283 return String::cast(constructor->shared()->instance_class_name());
3113 } 3284 }
3114 // If the constructor is not present, return "Object". 3285 // If the constructor is not present, return "Object".
(...skipping 9436 matching lines...) Expand 10 before | Expand all | Expand 10 after
12551 case HEAP_NUMBER_TYPE: 12722 case HEAP_NUMBER_TYPE:
12552 case JS_BOUND_FUNCTION_TYPE: 12723 case JS_BOUND_FUNCTION_TYPE:
12553 case JS_GLOBAL_OBJECT_TYPE: 12724 case JS_GLOBAL_OBJECT_TYPE:
12554 case JS_GLOBAL_PROXY_TYPE: 12725 case JS_GLOBAL_PROXY_TYPE:
12555 case JS_PROXY_TYPE: 12726 case JS_PROXY_TYPE:
12556 case MAP_TYPE: 12727 case MAP_TYPE:
12557 case MUTABLE_HEAP_NUMBER_TYPE: 12728 case MUTABLE_HEAP_NUMBER_TYPE:
12558 case ODDBALL_TYPE: 12729 case ODDBALL_TYPE:
12559 case PROPERTY_CELL_TYPE: 12730 case PROPERTY_CELL_TYPE:
12560 case SHARED_FUNCTION_INFO_TYPE: 12731 case SHARED_FUNCTION_INFO_TYPE:
12732 case SIMD128_VALUE_TYPE:
12561 case SYMBOL_TYPE: 12733 case SYMBOL_TYPE:
12562 case WEAK_CELL_TYPE: 12734 case WEAK_CELL_TYPE:
12563 12735
12564 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ 12736 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
12565 case FIXED_##TYPE##_ARRAY_TYPE: 12737 case FIXED_##TYPE##_ARRAY_TYPE:
12566 #undef TYPED_ARRAY_CASE 12738 #undef TYPED_ARRAY_CASE
12567 12739
12568 #define MAKE_STRUCT_CASE(NAME, Name, name) case NAME##_TYPE: 12740 #define MAKE_STRUCT_CASE(NAME, Name, name) case NAME##_TYPE:
12569 STRUCT_LIST(MAKE_STRUCT_CASE) 12741 STRUCT_LIST(MAKE_STRUCT_CASE)
12570 #undef MAKE_STRUCT_CASE 12742 #undef MAKE_STRUCT_CASE
(...skipping 7489 matching lines...) Expand 10 before | Expand all | Expand 10 after
20060 // depend on this. 20232 // depend on this.
20061 return DICTIONARY_ELEMENTS; 20233 return DICTIONARY_ELEMENTS;
20062 } 20234 }
20063 DCHECK_LE(kind, LAST_ELEMENTS_KIND); 20235 DCHECK_LE(kind, LAST_ELEMENTS_KIND);
20064 return kind; 20236 return kind;
20065 } 20237 }
20066 } 20238 }
20067 20239
20068 } // namespace internal 20240 } // namespace internal
20069 } // namespace v8 20241 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-body-descriptors-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698