| OLD | NEW |
| 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 1907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1918 PrototypeIterator iter(isolate, object, kStartAtReceiver); | 1918 PrototypeIterator iter(isolate, object, kStartAtReceiver); |
| 1919 while (true) { | 1919 while (true) { |
| 1920 if (!iter.AdvanceFollowingProxies()) return Nothing<bool>(); | 1920 if (!iter.AdvanceFollowingProxies()) return Nothing<bool>(); |
| 1921 if (iter.IsAtEnd()) return Just(false); | 1921 if (iter.IsAtEnd()) return Just(false); |
| 1922 if (PrototypeIterator::GetCurrent(iter).is_identical_to(proto)) { | 1922 if (PrototypeIterator::GetCurrent(iter).is_identical_to(proto)) { |
| 1923 return Just(true); | 1923 return Just(true); |
| 1924 } | 1924 } |
| 1925 } | 1925 } |
| 1926 } | 1926 } |
| 1927 | 1927 |
| 1928 Map* Object::GetRootMap(Isolate* isolate) { | 1928 Map* Object::GetPrototypeChainRootMap(Isolate* isolate) { |
| 1929 DisallowHeapAllocation no_alloc; | 1929 DisallowHeapAllocation no_alloc; |
| 1930 if (IsSmi()) { | 1930 if (IsSmi()) { |
| 1931 Context* native_context = isolate->context()->native_context(); | 1931 Context* native_context = isolate->context()->native_context(); |
| 1932 return native_context->number_function()->initial_map(); | 1932 return native_context->number_function()->initial_map(); |
| 1933 } | 1933 } |
| 1934 | 1934 |
| 1935 // The object is either a number, a string, a symbol, a boolean, a SIMD value, | 1935 // The object is either a number, a string, a symbol, a boolean, a SIMD value, |
| 1936 // a real JS object, or a Harmony proxy. | 1936 // a real JS object, or a Harmony proxy. |
| 1937 HeapObject* heap_object = HeapObject::cast(this); | 1937 HeapObject* heap_object = HeapObject::cast(this); |
| 1938 if (heap_object->IsJSReceiver()) { | 1938 return heap_object->map()->GetPrototypeChainRootMap(isolate); |
| 1939 return heap_object->map(); | 1939 } |
| 1940 |
| 1941 Map* Map::GetPrototypeChainRootMap(Isolate* isolate) { |
| 1942 DisallowHeapAllocation no_alloc; |
| 1943 if (IsJSReceiverMap()) { |
| 1944 return this; |
| 1940 } | 1945 } |
| 1941 int constructor_function_index = | 1946 int constructor_function_index = GetConstructorFunctionIndex(); |
| 1942 heap_object->map()->GetConstructorFunctionIndex(); | |
| 1943 if (constructor_function_index != Map::kNoConstructorFunctionIndex) { | 1947 if (constructor_function_index != Map::kNoConstructorFunctionIndex) { |
| 1944 Context* native_context = isolate->context()->native_context(); | 1948 Context* native_context = isolate->context()->native_context(); |
| 1945 JSFunction* constructor_function = | 1949 JSFunction* constructor_function = |
| 1946 JSFunction::cast(native_context->get(constructor_function_index)); | 1950 JSFunction::cast(native_context->get(constructor_function_index)); |
| 1947 return constructor_function->initial_map(); | 1951 return constructor_function->initial_map(); |
| 1948 } | 1952 } |
| 1949 return isolate->heap()->null_value()->map(); | 1953 return isolate->heap()->null_value()->map(); |
| 1950 } | 1954 } |
| 1951 | 1955 |
| 1952 namespace { | 1956 namespace { |
| (...skipping 10768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12721 if (value == false && !map->prototype_info()->IsPrototypeInfo()) { | 12725 if (value == false && !map->prototype_info()->IsPrototypeInfo()) { |
| 12722 // "False" is the implicit default value, so there's nothing to do. | 12726 // "False" is the implicit default value, so there's nothing to do. |
| 12723 return; | 12727 return; |
| 12724 } | 12728 } |
| 12725 GetOrCreatePrototypeInfo(map, isolate)->set_should_be_fast_map(value); | 12729 GetOrCreatePrototypeInfo(map, isolate)->set_should_be_fast_map(value); |
| 12726 } | 12730 } |
| 12727 | 12731 |
| 12728 // static | 12732 // static |
| 12729 Handle<Cell> Map::GetOrCreatePrototypeChainValidityCell(Handle<Map> map, | 12733 Handle<Cell> Map::GetOrCreatePrototypeChainValidityCell(Handle<Map> map, |
| 12730 Isolate* isolate) { | 12734 Isolate* isolate) { |
| 12731 Handle<Object> maybe_prototype(map->prototype(), isolate); | 12735 Handle<Object> maybe_prototype( |
| 12736 map->GetPrototypeChainRootMap(isolate)->prototype(), isolate); |
| 12732 if (!maybe_prototype->IsJSObject()) return Handle<Cell>::null(); | 12737 if (!maybe_prototype->IsJSObject()) return Handle<Cell>::null(); |
| 12733 Handle<JSObject> prototype = Handle<JSObject>::cast(maybe_prototype); | 12738 Handle<JSObject> prototype = Handle<JSObject>::cast(maybe_prototype); |
| 12734 // Ensure the prototype is registered with its own prototypes so its cell | 12739 // Ensure the prototype is registered with its own prototypes so its cell |
| 12735 // will be invalidated when necessary. | 12740 // will be invalidated when necessary. |
| 12736 JSObject::LazyRegisterPrototypeUser(handle(prototype->map(), isolate), | 12741 JSObject::LazyRegisterPrototypeUser(handle(prototype->map(), isolate), |
| 12737 isolate); | 12742 isolate); |
| 12738 Handle<PrototypeInfo> proto_info = | 12743 Handle<PrototypeInfo> proto_info = |
| 12739 GetOrCreatePrototypeInfo(prototype, isolate); | 12744 GetOrCreatePrototypeInfo(prototype, isolate); |
| 12740 Object* maybe_cell = proto_info->validity_cell(); | 12745 Object* maybe_cell = proto_info->validity_cell(); |
| 12741 // Return existing cell if it's still valid. | 12746 // Return existing cell if it's still valid. |
| (...skipping 7514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20256 ns, Accessors::ModuleNamespaceEntryInfo(isolate, name, attr)) | 20261 ns, Accessors::ModuleNamespaceEntryInfo(isolate, name, attr)) |
| 20257 .Check(); | 20262 .Check(); |
| 20258 } | 20263 } |
| 20259 JSObject::PreventExtensions(ns, THROW_ON_ERROR).ToChecked(); | 20264 JSObject::PreventExtensions(ns, THROW_ON_ERROR).ToChecked(); |
| 20260 | 20265 |
| 20261 return ns; | 20266 return ns; |
| 20262 } | 20267 } |
| 20263 | 20268 |
| 20264 } // namespace internal | 20269 } // namespace internal |
| 20265 } // namespace v8 | 20270 } // namespace v8 |
| OLD | NEW |