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/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/allocation-site-scopes.h" | 8 #include "src/allocation-site-scopes.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 2586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2597 function_mode == FUNCTION_WITH_WRITEABLE_PROTOTYPE ? rw_attribs | 2597 function_mode == FUNCTION_WITH_WRITEABLE_PROTOTYPE ? rw_attribs |
2598 : ro_attribs; | 2598 : ro_attribs; |
2599 Handle<AccessorInfo> prototype = | 2599 Handle<AccessorInfo> prototype = |
2600 Accessors::FunctionPrototypeInfo(isolate(), attribs); | 2600 Accessors::FunctionPrototypeInfo(isolate(), attribs); |
2601 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), | 2601 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), |
2602 prototype, attribs); | 2602 prototype, attribs); |
2603 map->AppendDescriptor(&d); | 2603 map->AppendDescriptor(&d); |
2604 } | 2604 } |
2605 } | 2605 } |
2606 | 2606 |
| 2607 Handle<Map> Factory::CreateClassFunctionMap(Handle<JSFunction> empty_function) { |
| 2608 Handle<Map> map = NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); |
| 2609 SetClassFunctionInstanceDescriptor(map); |
| 2610 map->set_is_constructor(true); |
| 2611 map->set_is_callable(); |
| 2612 Map::SetPrototype(map, empty_function); |
| 2613 return map; |
| 2614 } |
| 2615 |
| 2616 void Factory::SetClassFunctionInstanceDescriptor(Handle<Map> map) { |
| 2617 int size = 3; // with prototype |
| 2618 Map::EnsureDescriptorSlack(map, size); |
| 2619 |
| 2620 PropertyAttributes rw_attribs = |
| 2621 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); |
| 2622 PropertyAttributes roc_attribs = |
| 2623 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY); |
| 2624 |
| 2625 STATIC_ASSERT(JSFunction::kLengthDescriptorIndex == 0); |
| 2626 { // Add length. |
| 2627 Handle<AccessorInfo> length = |
| 2628 Accessors::FunctionLengthInfo(isolate(), roc_attribs); |
| 2629 AccessorConstantDescriptor d(handle(Name::cast(length->name())), length, |
| 2630 roc_attribs); |
| 2631 map->AppendDescriptor(&d); |
| 2632 } |
| 2633 |
| 2634 { |
| 2635 // Add prototype. |
| 2636 Handle<AccessorInfo> prototype = |
| 2637 Accessors::FunctionPrototypeInfo(isolate(), rw_attribs); |
| 2638 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), |
| 2639 prototype, rw_attribs); |
| 2640 map->AppendDescriptor(&d); |
| 2641 } |
| 2642 } |
| 2643 |
2607 } // namespace internal | 2644 } // namespace internal |
2608 } // namespace v8 | 2645 } // namespace v8 |
OLD | NEW |