OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 <iomanip> | 5 #include <iomanip> |
6 #include <sstream> | 6 #include <sstream> |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 90 } |
91 | 91 |
92 | 92 |
93 bool Object::BooleanValue() { | 93 bool Object::BooleanValue() { |
94 if (IsBoolean()) return IsTrue(); | 94 if (IsBoolean()) return IsTrue(); |
95 if (IsSmi()) return Smi::cast(this)->value() != 0; | 95 if (IsSmi()) return Smi::cast(this)->value() != 0; |
96 if (IsUndefined() || IsNull()) return false; | 96 if (IsUndefined() || IsNull()) return false; |
97 if (IsUndetectableObject()) return false; // Undetectable object is false. | 97 if (IsUndetectableObject()) return false; // Undetectable object is false. |
98 if (IsString()) return String::cast(this)->length() != 0; | 98 if (IsString()) return String::cast(this)->length() != 0; |
99 if (IsHeapNumber()) return HeapNumber::cast(this)->HeapNumberBooleanValue(); | 99 if (IsHeapNumber()) return HeapNumber::cast(this)->HeapNumberBooleanValue(); |
| 100 if (IsFloat32x4()) return true; // Simd value types always evaluate to true. |
100 return true; | 101 return true; |
101 } | 102 } |
102 | 103 |
103 | 104 |
104 bool Object::IsCallable() const { | 105 bool Object::IsCallable() const { |
105 const Object* fun = this; | 106 const Object* fun = this; |
106 while (fun->IsJSFunctionProxy()) { | 107 while (fun->IsJSFunctionProxy()) { |
107 fun = JSFunctionProxy::cast(fun)->call_trap(); | 108 fun = JSFunctionProxy::cast(fun)->call_trap(); |
108 } | 109 } |
109 return fun->IsJSFunction() || | 110 return fun->IsJSFunction() || |
(...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1393 HeapNumber::cast(this)->HeapNumberPrint(os); | 1394 HeapNumber::cast(this)->HeapNumberPrint(os); |
1394 os << ">"; | 1395 os << ">"; |
1395 break; | 1396 break; |
1396 } | 1397 } |
1397 case MUTABLE_HEAP_NUMBER_TYPE: { | 1398 case MUTABLE_HEAP_NUMBER_TYPE: { |
1398 os << "<MutableNumber: "; | 1399 os << "<MutableNumber: "; |
1399 HeapNumber::cast(this)->HeapNumberPrint(os); | 1400 HeapNumber::cast(this)->HeapNumberPrint(os); |
1400 os << '>'; | 1401 os << '>'; |
1401 break; | 1402 break; |
1402 } | 1403 } |
| 1404 case FLOAT32X4_TYPE: { |
| 1405 os << "<Float32x4: "; |
| 1406 Float32x4::cast(this)->Float32x4Print(os); |
| 1407 os << ">"; |
| 1408 break; |
| 1409 } |
1403 case JS_PROXY_TYPE: | 1410 case JS_PROXY_TYPE: |
1404 os << "<JSProxy>"; | 1411 os << "<JSProxy>"; |
1405 break; | 1412 break; |
1406 case JS_FUNCTION_PROXY_TYPE: | 1413 case JS_FUNCTION_PROXY_TYPE: |
1407 os << "<JSFunctionProxy>"; | 1414 os << "<JSFunctionProxy>"; |
1408 break; | 1415 break; |
1409 case FOREIGN_TYPE: | 1416 case FOREIGN_TYPE: |
1410 os << "<Foreign>"; | 1417 os << "<Foreign>"; |
1411 break; | 1418 break; |
1412 case CELL_TYPE: { | 1419 case CELL_TYPE: { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1539 break; | 1546 break; |
1540 case WEAK_CELL_TYPE: | 1547 case WEAK_CELL_TYPE: |
1541 WeakCell::BodyDescriptor::IterateBody(this, v); | 1548 WeakCell::BodyDescriptor::IterateBody(this, v); |
1542 break; | 1549 break; |
1543 case SYMBOL_TYPE: | 1550 case SYMBOL_TYPE: |
1544 Symbol::BodyDescriptor::IterateBody(this, v); | 1551 Symbol::BodyDescriptor::IterateBody(this, v); |
1545 break; | 1552 break; |
1546 | 1553 |
1547 case HEAP_NUMBER_TYPE: | 1554 case HEAP_NUMBER_TYPE: |
1548 case MUTABLE_HEAP_NUMBER_TYPE: | 1555 case MUTABLE_HEAP_NUMBER_TYPE: |
| 1556 case FLOAT32X4_TYPE: |
1549 case FILLER_TYPE: | 1557 case FILLER_TYPE: |
1550 case BYTE_ARRAY_TYPE: | 1558 case BYTE_ARRAY_TYPE: |
1551 case FREE_SPACE_TYPE: | 1559 case FREE_SPACE_TYPE: |
1552 break; | 1560 break; |
1553 | 1561 |
1554 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | 1562 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
1555 case EXTERNAL_##TYPE##_ARRAY_TYPE: \ | 1563 case EXTERNAL_##TYPE##_ARRAY_TYPE: \ |
1556 case FIXED_##TYPE##_ARRAY_TYPE: \ | 1564 case FIXED_##TYPE##_ARRAY_TYPE: \ |
1557 break; | 1565 break; |
1558 | 1566 |
(...skipping 25 matching lines...) Expand all Loading... |
1584 bool HeapNumber::HeapNumberBooleanValue() { | 1592 bool HeapNumber::HeapNumberBooleanValue() { |
1585 return DoubleToBoolean(value()); | 1593 return DoubleToBoolean(value()); |
1586 } | 1594 } |
1587 | 1595 |
1588 | 1596 |
1589 void HeapNumber::HeapNumberPrint(std::ostream& os) { // NOLINT | 1597 void HeapNumber::HeapNumberPrint(std::ostream& os) { // NOLINT |
1590 os << value(); | 1598 os << value(); |
1591 } | 1599 } |
1592 | 1600 |
1593 | 1601 |
| 1602 void Float32x4::Float32x4Print(std::ostream& os) { // NOLINT |
| 1603 os << get_lane(0) << ", " << get_lane(1) << ", " << get_lane(2) << ", " |
| 1604 << get_lane(3); |
| 1605 } |
| 1606 |
| 1607 |
1594 String* JSReceiver::class_name() { | 1608 String* JSReceiver::class_name() { |
1595 if (IsJSFunction() || IsJSFunctionProxy()) { | 1609 if (IsJSFunction() || IsJSFunctionProxy()) { |
1596 return GetHeap()->Function_string(); | 1610 return GetHeap()->Function_string(); |
1597 } | 1611 } |
1598 Object* maybe_constructor = map()->GetConstructor(); | 1612 Object* maybe_constructor = map()->GetConstructor(); |
1599 if (maybe_constructor->IsJSFunction()) { | 1613 if (maybe_constructor->IsJSFunction()) { |
1600 JSFunction* constructor = JSFunction::cast(maybe_constructor); | 1614 JSFunction* constructor = JSFunction::cast(maybe_constructor); |
1601 return String::cast(constructor->shared()->instance_class_name()); | 1615 return String::cast(constructor->shared()->instance_class_name()); |
1602 } | 1616 } |
1603 // If the constructor is not present, return "Object". | 1617 // If the constructor is not present, return "Object". |
(...skipping 15390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16994 Handle<Object> new_value) { | 17008 Handle<Object> new_value) { |
16995 if (cell->value() != *new_value) { | 17009 if (cell->value() != *new_value) { |
16996 cell->set_value(*new_value); | 17010 cell->set_value(*new_value); |
16997 Isolate* isolate = cell->GetIsolate(); | 17011 Isolate* isolate = cell->GetIsolate(); |
16998 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 17012 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
16999 isolate, DependentCode::kPropertyCellChangedGroup); | 17013 isolate, DependentCode::kPropertyCellChangedGroup); |
17000 } | 17014 } |
17001 } | 17015 } |
17002 } // namespace internal | 17016 } // namespace internal |
17003 } // namespace v8 | 17017 } // namespace v8 |
OLD | NEW |