OLD | NEW |
1 // Copyright 2017 the V8 project authors. All rights reserved. | 1 // Copyright 2017 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/ffi/ffi-compiler.h" | 5 #include "src/ffi/ffi-compiler.h" |
6 #include "src/api.h" | 6 #include "src/api.h" |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/objects-inl.h" | 8 #include "src/objects-inl.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
11 namespace internal { | 11 namespace internal { |
12 | 12 |
13 void InstallFFIMap(Isolate* isolate) { | 13 void InstallFFIMap(Isolate* isolate) { |
14 Handle<Context> context(isolate->context()); | 14 Handle<Context> context(isolate->context()); |
15 DCHECK(!context->get(Context::NATIVE_FUNCTION_MAP_INDEX)->IsMap()); | 15 DCHECK(!context->get(Context::NATIVE_FUNCTION_MAP_INDEX)->IsMap()); |
16 Handle<Map> prev_map = Handle<Map>(context->sloppy_function_map(), isolate); | 16 Handle<Map> prev_map = Handle<Map>(context->sloppy_function_map(), isolate); |
17 | 17 |
18 InstanceType instance_type = prev_map->instance_type(); | 18 InstanceType instance_type = prev_map->instance_type(); |
19 int internal_fields = JSObject::GetInternalFieldCount(*prev_map); | 19 int embedder_fields = JSObject::GetEmbedderFieldCount(*prev_map); |
20 CHECK_EQ(0, internal_fields); | 20 CHECK_EQ(0, embedder_fields); |
21 int pre_allocated = | 21 int pre_allocated = |
22 prev_map->GetInObjectProperties() - prev_map->unused_property_fields(); | 22 prev_map->GetInObjectProperties() - prev_map->unused_property_fields(); |
23 int instance_size; | 23 int instance_size; |
24 int in_object_properties; | 24 int in_object_properties; |
25 JSFunction::CalculateInstanceSizeHelper( | 25 JSFunction::CalculateInstanceSizeHelper( |
26 instance_type, internal_fields, 0, &instance_size, &in_object_properties); | 26 instance_type, embedder_fields, 0, &instance_size, &in_object_properties); |
27 int unused_property_fields = in_object_properties - pre_allocated; | 27 int unused_property_fields = in_object_properties - pre_allocated; |
28 Handle<Map> map = Map::CopyInitialMap( | 28 Handle<Map> map = Map::CopyInitialMap( |
29 prev_map, instance_size, in_object_properties, unused_property_fields); | 29 prev_map, instance_size, in_object_properties, unused_property_fields); |
30 context->set_native_function_map(*map); | 30 context->set_native_function_map(*map); |
31 } | 31 } |
32 | 32 |
33 namespace ffi { | 33 namespace ffi { |
34 | 34 |
35 class FFIAssembler : public CodeStubAssembler { | 35 class FFIAssembler : public CodeStubAssembler { |
36 public: | 36 public: |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 shared->set_internal_formal_parameter_count(params); | 119 shared->set_internal_formal_parameter_count(params); |
120 Handle<JSFunction> function = isolate->factory()->NewFunction( | 120 Handle<JSFunction> function = isolate->factory()->NewFunction( |
121 isolate->native_function_map(), name, code); | 121 isolate->native_function_map(), name, code); |
122 function->set_shared(*shared); | 122 function->set_shared(*shared); |
123 return function; | 123 return function; |
124 } | 124 } |
125 | 125 |
126 } // namespace ffi | 126 } // namespace ffi |
127 } // namespace internal | 127 } // namespace internal |
128 } // namespace v8 | 128 } // namespace v8 |
OLD | NEW |