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 4676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4687 if (isolate->has_pending_exception()) return Nothing<bool>(); | 4687 if (isolate->has_pending_exception()) return Nothing<bool>(); |
4688 if (owned && !target_desc.configurable()) { | 4688 if (owned && !target_desc.configurable()) { |
4689 isolate->Throw(*factory->NewTypeError( | 4689 isolate->Throw(*factory->NewTypeError( |
4690 MessageTemplate::kProxyDeletePropertyViolatesInvariant, name)); | 4690 MessageTemplate::kProxyDeletePropertyViolatesInvariant, name)); |
4691 return Nothing<bool>(); | 4691 return Nothing<bool>(); |
4692 } | 4692 } |
4693 return Just(true); | 4693 return Just(true); |
4694 } | 4694 } |
4695 | 4695 |
4696 | 4696 |
| 4697 // static |
| 4698 MaybeHandle<Context> JSProxy::GetFunctionRealm(Handle<JSProxy> proxy) { |
| 4699 DCHECK(proxy->map()->is_constructor()); |
| 4700 if (JSProxy::IsRevoked(proxy)) { |
| 4701 THROW_NEW_ERROR(proxy->GetIsolate(), |
| 4702 NewTypeError(MessageTemplate::kProxyRevoked), Context); |
| 4703 } |
| 4704 |
| 4705 // TODO(verwaest): Get rid of JSFunctionProxies. |
| 4706 Object* target = proxy->IsJSFunctionProxy() |
| 4707 ? JSFunctionProxy::cast(*proxy)->construct_trap() |
| 4708 : proxy->target(); |
| 4709 return JSReceiver::GetFunctionRealm(handle(JSReceiver::cast(target))); |
| 4710 } |
| 4711 |
| 4712 |
| 4713 // static |
| 4714 MaybeHandle<Context> JSFunction::GetFunctionRealm(Handle<JSFunction> function) { |
| 4715 DCHECK(function->map()->is_constructor()); |
| 4716 return handle(function->context()->native_context()); |
| 4717 } |
| 4718 |
| 4719 |
| 4720 // static |
| 4721 MaybeHandle<Context> JSObject::GetFunctionRealm(Handle<JSObject> object) { |
| 4722 DCHECK(object->map()->is_constructor()); |
| 4723 DCHECK(!object->IsJSFunction()); |
| 4724 return handle(object->GetCreationContext()); |
| 4725 } |
| 4726 |
| 4727 |
| 4728 // static |
| 4729 MaybeHandle<Context> JSReceiver::GetFunctionRealm(Handle<JSReceiver> receiver) { |
| 4730 if (receiver->IsJSProxy()) { |
| 4731 return JSProxy::GetFunctionRealm(Handle<JSProxy>::cast(receiver)); |
| 4732 } |
| 4733 |
| 4734 if (receiver->IsJSFunction()) { |
| 4735 return JSFunction::GetFunctionRealm(Handle<JSFunction>::cast(receiver)); |
| 4736 } |
| 4737 |
| 4738 return JSObject::GetFunctionRealm(Handle<JSObject>::cast(receiver)); |
| 4739 } |
| 4740 |
| 4741 |
4697 Maybe<PropertyAttributes> JSProxy::GetPropertyAttributes(LookupIterator* it) { | 4742 Maybe<PropertyAttributes> JSProxy::GetPropertyAttributes(LookupIterator* it) { |
4698 Isolate* isolate = it->isolate(); | 4743 Isolate* isolate = it->isolate(); |
4699 HandleScope scope(isolate); | 4744 HandleScope scope(isolate); |
4700 PropertyDescriptor desc; | 4745 PropertyDescriptor desc; |
4701 bool found = JSProxy::GetOwnPropertyDescriptor(it, &desc); | 4746 bool found = JSProxy::GetOwnPropertyDescriptor(it, &desc); |
4702 if (isolate->has_pending_exception()) return Nothing<PropertyAttributes>(); | 4747 if (isolate->has_pending_exception()) return Nothing<PropertyAttributes>(); |
4703 if (!found) return Just(ABSENT); | 4748 if (!found) return Just(ABSENT); |
4704 return Just(desc.ToAttributes()); | 4749 return Just(desc.ToAttributes()); |
4705 } | 4750 } |
4706 | 4751 |
(...skipping 7481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12188 return handle(new_target->initial_map(), isolate); | 12233 return handle(new_target->initial_map(), isolate); |
12189 } | 12234 } |
12190 } | 12235 } |
12191 | 12236 |
12192 // First create a new map with the size and number of in-object properties | 12237 // First create a new map with the size and number of in-object properties |
12193 // suggested by the function. | 12238 // suggested by the function. |
12194 DCHECK(!new_target->shared()->is_generator()); | 12239 DCHECK(!new_target->shared()->is_generator()); |
12195 DCHECK(!constructor->shared()->is_generator()); | 12240 DCHECK(!constructor->shared()->is_generator()); |
12196 | 12241 |
12197 // Fetch or allocate prototype. | 12242 // Fetch or allocate prototype. |
| 12243 // TODO(verwaest): In case of non-instance prototype, use the |
| 12244 // intrinsicDefaultProto instead. |
12198 Handle<Object> prototype; | 12245 Handle<Object> prototype; |
12199 if (new_target->has_instance_prototype()) { | 12246 if (new_target->has_instance_prototype()) { |
12200 prototype = handle(new_target->instance_prototype(), isolate); | 12247 prototype = handle(new_target->instance_prototype(), isolate); |
12201 } else { | 12248 } else { |
12202 prototype = isolate->factory()->NewFunctionPrototype(new_target); | 12249 prototype = isolate->factory()->NewFunctionPrototype(new_target); |
12203 } | 12250 } |
12204 | 12251 |
12205 // Finally link initial map and constructor function if the original | 12252 // Finally link initial map and constructor function if the original |
12206 // constructor is actually a subclass constructor. | 12253 // constructor is actually a subclass constructor. |
12207 if (IsSubclassConstructor(new_target->shared()->kind())) { | 12254 if (IsSubclassConstructor(new_target->shared()->kind())) { |
(...skipping 6376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18584 if (cell->value() != *new_value) { | 18631 if (cell->value() != *new_value) { |
18585 cell->set_value(*new_value); | 18632 cell->set_value(*new_value); |
18586 Isolate* isolate = cell->GetIsolate(); | 18633 Isolate* isolate = cell->GetIsolate(); |
18587 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 18634 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
18588 isolate, DependentCode::kPropertyCellChangedGroup); | 18635 isolate, DependentCode::kPropertyCellChangedGroup); |
18589 } | 18636 } |
18590 } | 18637 } |
18591 | 18638 |
18592 } // namespace internal | 18639 } // namespace internal |
18593 } // namespace v8 | 18640 } // namespace v8 |
OLD | NEW |