| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/factory.h" | 5 #include "src/factory.h" |
| 6 | 6 |
| 7 #include "src/allocation-site-scopes.h" | 7 #include "src/allocation-site-scopes.h" |
| 8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
| (...skipping 2016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2027 CALL_HEAP_FUNCTION( | 2027 CALL_HEAP_FUNCTION( |
| 2028 isolate(), isolate()->heap()->AllocateJSObjectFromMap(*map, NOT_TENURED), | 2028 isolate(), isolate()->heap()->AllocateJSObjectFromMap(*map, NOT_TENURED), |
| 2029 JSGlobalProxy); | 2029 JSGlobalProxy); |
| 2030 } | 2030 } |
| 2031 | 2031 |
| 2032 | 2032 |
| 2033 void Factory::ReinitializeJSGlobalProxy(Handle<JSGlobalProxy> object, | 2033 void Factory::ReinitializeJSGlobalProxy(Handle<JSGlobalProxy> object, |
| 2034 Handle<JSFunction> constructor) { | 2034 Handle<JSFunction> constructor) { |
| 2035 DCHECK(constructor->has_initial_map()); | 2035 DCHECK(constructor->has_initial_map()); |
| 2036 Handle<Map> map(constructor->initial_map(), isolate()); | 2036 Handle<Map> map(constructor->initial_map(), isolate()); |
| 2037 Handle<Map> old_map(object->map(), isolate()); |
| 2037 | 2038 |
| 2038 // The proxy's hash should be retained across reinitialization. | 2039 // The proxy's hash should be retained across reinitialization. |
| 2039 Handle<Object> hash(object->hash(), isolate()); | 2040 Handle<Object> hash(object->hash(), isolate()); |
| 2040 | 2041 |
| 2042 JSObject::InvalidatePrototypeChains(*old_map); |
| 2043 if (old_map->is_prototype_map()) { |
| 2044 map = Map::Copy(map, "CopyAsPrototypeForJSGlobalProxy"); |
| 2045 map->set_is_prototype_map(true); |
| 2046 } |
| 2047 JSObject::UpdatePrototypeUserRegistration(old_map, map, isolate()); |
| 2048 |
| 2041 // Check that the already allocated object has the same size and type as | 2049 // Check that the already allocated object has the same size and type as |
| 2042 // objects allocated using the constructor. | 2050 // objects allocated using the constructor. |
| 2043 DCHECK(map->instance_size() == object->map()->instance_size()); | 2051 DCHECK(map->instance_size() == old_map->instance_size()); |
| 2044 DCHECK(map->instance_type() == object->map()->instance_type()); | 2052 DCHECK(map->instance_type() == old_map->instance_type()); |
| 2045 | 2053 |
| 2046 // Allocate the backing storage for the properties. | 2054 // Allocate the backing storage for the properties. |
| 2047 Handle<FixedArray> properties = empty_fixed_array(); | 2055 Handle<FixedArray> properties = empty_fixed_array(); |
| 2048 | 2056 |
| 2049 // In order to keep heap in consistent state there must be no allocations | 2057 // In order to keep heap in consistent state there must be no allocations |
| 2050 // before object re-initialization is finished. | 2058 // before object re-initialization is finished. |
| 2051 DisallowHeapAllocation no_allocation; | 2059 DisallowHeapAllocation no_allocation; |
| 2052 | 2060 |
| 2053 // Reset the map for the object. | 2061 // Reset the map for the object. |
| 2054 object->synchronized_set_map(*map); | 2062 object->synchronized_set_map(*map); |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2376 } | 2384 } |
| 2377 | 2385 |
| 2378 | 2386 |
| 2379 Handle<Object> Factory::ToBoolean(bool value) { | 2387 Handle<Object> Factory::ToBoolean(bool value) { |
| 2380 return value ? true_value() : false_value(); | 2388 return value ? true_value() : false_value(); |
| 2381 } | 2389 } |
| 2382 | 2390 |
| 2383 | 2391 |
| 2384 } // namespace internal | 2392 } // namespace internal |
| 2385 } // namespace v8 | 2393 } // namespace v8 |
| OLD | NEW |