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 "src/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 4636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4647 } | 4647 } |
4648 | 4648 |
4649 int attributes = NONE; | 4649 int attributes = NONE; |
4650 if (!enumerable->BooleanValue()) attributes |= DONT_ENUM; | 4650 if (!enumerable->BooleanValue()) attributes |= DONT_ENUM; |
4651 if (!configurable->BooleanValue()) attributes |= DONT_DELETE; | 4651 if (!configurable->BooleanValue()) attributes |= DONT_DELETE; |
4652 if (!writable->BooleanValue()) attributes |= READ_ONLY; | 4652 if (!writable->BooleanValue()) attributes |= READ_ONLY; |
4653 return Just(static_cast<PropertyAttributes>(attributes)); | 4653 return Just(static_cast<PropertyAttributes>(attributes)); |
4654 } | 4654 } |
4655 | 4655 |
4656 | 4656 |
4657 void JSProxy::Fix(Handle<JSProxy> proxy) { | |
4658 Isolate* isolate = proxy->GetIsolate(); | |
4659 | |
4660 // Save identity hash. | |
4661 Handle<Object> hash(proxy->GetIdentityHash(), isolate); | |
4662 | |
4663 if (proxy->IsJSFunctionProxy()) { | |
4664 isolate->factory()->BecomeJSFunction(proxy); | |
4665 // Code will be set on the JavaScript side. | |
4666 } else { | |
4667 isolate->factory()->BecomeJSObject(proxy); | |
4668 } | |
4669 DCHECK(proxy->IsJSObject()); | |
4670 | |
4671 // Inherit identity, if it was present. | |
4672 if (hash->IsSmi()) { | |
4673 JSObject::SetIdentityHash(Handle<JSObject>::cast(proxy), | |
4674 Handle<Smi>::cast(hash)); | |
4675 } | |
4676 } | |
4677 | |
4678 | |
4679 MaybeHandle<Object> JSProxy::CallTrap(Handle<JSProxy> proxy, | 4657 MaybeHandle<Object> JSProxy::CallTrap(Handle<JSProxy> proxy, |
4680 const char* name, | 4658 const char* name, |
4681 Handle<Object> derived, | 4659 Handle<Object> derived, |
4682 int argc, | 4660 int argc, |
4683 Handle<Object> argv[]) { | 4661 Handle<Object> argv[]) { |
4684 Isolate* isolate = proxy->GetIsolate(); | 4662 Isolate* isolate = proxy->GetIsolate(); |
4685 Handle<Object> handler(proxy->handler(), isolate); | 4663 Handle<Object> handler(proxy->handler(), isolate); |
4686 | 4664 |
4687 Handle<String> trap_name = isolate->factory()->InternalizeUtf8String(name); | 4665 Handle<String> trap_name = isolate->factory()->InternalizeUtf8String(name); |
4688 Handle<Object> trap; | 4666 Handle<Object> trap; |
(...skipping 3725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8414 map, new_desc, new_layout_descriptor, INSERT_TRANSITION, | 8392 map, new_desc, new_layout_descriptor, INSERT_TRANSITION, |
8415 transition_marker, reason, SPECIAL_TRANSITION); | 8393 transition_marker, reason, SPECIAL_TRANSITION); |
8416 new_map->set_is_extensible(false); | 8394 new_map->set_is_extensible(false); |
8417 if (!IsFixedTypedArrayElementsKind(map->elements_kind())) { | 8395 if (!IsFixedTypedArrayElementsKind(map->elements_kind())) { |
8418 new_map->set_elements_kind(DICTIONARY_ELEMENTS); | 8396 new_map->set_elements_kind(DICTIONARY_ELEMENTS); |
8419 } | 8397 } |
8420 return new_map; | 8398 return new_map; |
8421 } | 8399 } |
8422 | 8400 |
8423 | 8401 |
8424 Handle<Map> Map::FixProxy(Handle<Map> map, InstanceType type, int size) { | |
8425 DCHECK(type == JS_OBJECT_TYPE || type == JS_FUNCTION_TYPE); | |
8426 DCHECK(map->IsJSProxyMap()); | |
8427 | |
8428 Isolate* isolate = map->GetIsolate(); | |
8429 | |
8430 // Allocate fresh map. | |
8431 // TODO(rossberg): Once we optimize proxies, cache these maps. | |
8432 Handle<Map> new_map = isolate->factory()->NewMap(type, size); | |
8433 | |
8434 Handle<Object> prototype(map->prototype(), isolate); | |
8435 Map::SetPrototype(new_map, prototype); | |
8436 | |
8437 map->NotifyLeafMapLayoutChange(); | |
8438 | |
8439 return new_map; | |
8440 } | |
8441 | |
8442 | |
8443 bool DescriptorArray::CanHoldValue(int descriptor, Object* value) { | 8402 bool DescriptorArray::CanHoldValue(int descriptor, Object* value) { |
8444 PropertyDetails details = GetDetails(descriptor); | 8403 PropertyDetails details = GetDetails(descriptor); |
8445 switch (details.type()) { | 8404 switch (details.type()) { |
8446 case DATA: | 8405 case DATA: |
8447 return value->FitsRepresentation(details.representation()) && | 8406 return value->FitsRepresentation(details.representation()) && |
8448 GetFieldType(descriptor)->NowContains(value); | 8407 GetFieldType(descriptor)->NowContains(value); |
8449 | 8408 |
8450 case DATA_CONSTANT: | 8409 case DATA_CONSTANT: |
8451 DCHECK(GetConstant(descriptor) != value || | 8410 DCHECK(GetConstant(descriptor) != value || |
8452 value->FitsRepresentation(details.representation())); | 8411 value->FitsRepresentation(details.representation())); |
(...skipping 9448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17901 if (cell->value() != *new_value) { | 17860 if (cell->value() != *new_value) { |
17902 cell->set_value(*new_value); | 17861 cell->set_value(*new_value); |
17903 Isolate* isolate = cell->GetIsolate(); | 17862 Isolate* isolate = cell->GetIsolate(); |
17904 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 17863 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
17905 isolate, DependentCode::kPropertyCellChangedGroup); | 17864 isolate, DependentCode::kPropertyCellChangedGroup); |
17906 } | 17865 } |
17907 } | 17866 } |
17908 | 17867 |
17909 } // namespace internal | 17868 } // namespace internal |
17910 } // namespace v8 | 17869 } // namespace v8 |
OLD | NEW |