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 12714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12725 return cell; | 12725 return cell; |
12726 } | 12726 } |
12727 } | 12727 } |
12728 // Otherwise create a new cell. | 12728 // Otherwise create a new cell. |
12729 Handle<Cell> cell = isolate->factory()->NewCell( | 12729 Handle<Cell> cell = isolate->factory()->NewCell( |
12730 handle(Smi::FromInt(Map::kPrototypeChainValid), isolate)); | 12730 handle(Smi::FromInt(Map::kPrototypeChainValid), isolate)); |
12731 proto_info->set_validity_cell(*cell); | 12731 proto_info->set_validity_cell(*cell); |
12732 return cell; | 12732 return cell; |
12733 } | 12733 } |
12734 | 12734 |
| 12735 // static |
| 12736 Handle<WeakCell> Map::GetOrCreatePrototypeWeakCell(Handle<JSObject> prototype, |
| 12737 Isolate* isolate) { |
| 12738 DCHECK(!prototype.is_null()); |
| 12739 Handle<PrototypeInfo> proto_info = |
| 12740 GetOrCreatePrototypeInfo(prototype, isolate); |
| 12741 Object* maybe_cell = proto_info->weak_cell(); |
| 12742 // Return existing cell if it's already created. |
| 12743 if (maybe_cell->IsWeakCell()) { |
| 12744 Handle<WeakCell> cell(WeakCell::cast(maybe_cell), isolate); |
| 12745 DCHECK(!cell->cleared()); |
| 12746 return cell; |
| 12747 } |
| 12748 // Otherwise create a new cell. |
| 12749 Handle<WeakCell> cell = isolate->factory()->NewWeakCell(prototype); |
| 12750 proto_info->set_weak_cell(*cell); |
| 12751 return cell; |
| 12752 } |
12735 | 12753 |
12736 // static | 12754 // static |
12737 void Map::SetPrototype(Handle<Map> map, Handle<Object> prototype, | 12755 void Map::SetPrototype(Handle<Map> map, Handle<Object> prototype, |
12738 PrototypeOptimizationMode proto_mode) { | 12756 PrototypeOptimizationMode proto_mode) { |
12739 RuntimeCallTimerScope stats_scope(*map, &RuntimeCallStats::Map_SetPrototype); | 12757 RuntimeCallTimerScope stats_scope(*map, &RuntimeCallStats::Map_SetPrototype); |
12740 | 12758 |
12741 bool is_hidden = false; | 12759 bool is_hidden = false; |
12742 if (prototype->IsJSObject()) { | 12760 if (prototype->IsJSObject()) { |
12743 Handle<JSObject> prototype_jsobj = Handle<JSObject>::cast(prototype); | 12761 Handle<JSObject> prototype_jsobj = Handle<JSObject>::cast(prototype); |
12744 JSObject::OptimizeAsPrototype(prototype_jsobj, proto_mode); | 12762 JSObject::OptimizeAsPrototype(prototype_jsobj, proto_mode); |
(...skipping 7450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20195 ns, Accessors::ModuleNamespaceEntryInfo(isolate, name, attr)) | 20213 ns, Accessors::ModuleNamespaceEntryInfo(isolate, name, attr)) |
20196 .Check(); | 20214 .Check(); |
20197 } | 20215 } |
20198 JSObject::PreventExtensions(ns, THROW_ON_ERROR).ToChecked(); | 20216 JSObject::PreventExtensions(ns, THROW_ON_ERROR).ToChecked(); |
20199 | 20217 |
20200 return ns; | 20218 return ns; |
20201 } | 20219 } |
20202 | 20220 |
20203 } // namespace internal | 20221 } // namespace internal |
20204 } // namespace v8 | 20222 } // namespace v8 |
OLD | NEW |