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 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1199 return function; | 1199 return function; |
1200 } | 1200 } |
1201 | 1201 |
1202 | 1202 |
1203 Handle<JSFunction> Factory::NewFunction(Handle<Map> map, | 1203 Handle<JSFunction> Factory::NewFunction(Handle<Map> map, |
1204 Handle<String> name, | 1204 Handle<String> name, |
1205 MaybeHandle<Code> code) { | 1205 MaybeHandle<Code> code) { |
1206 Handle<Context> context(isolate()->native_context()); | 1206 Handle<Context> context(isolate()->native_context()); |
1207 Handle<SharedFunctionInfo> info = | 1207 Handle<SharedFunctionInfo> info = |
1208 NewSharedFunctionInfo(name, code, map->is_constructor()); | 1208 NewSharedFunctionInfo(name, code, map->is_constructor()); |
1209 DCHECK(is_sloppy(info->language_mode()) && | 1209 DCHECK(is_sloppy(info->language_mode())); |
1210 (map.is_identical_to(isolate()->sloppy_function_map()) || | 1210 DCHECK( |
1211 map.is_identical_to( | 1211 map.is_identical_to(isolate()->sloppy_function_map()) || |
1212 isolate()->sloppy_function_without_prototype_map()) || | 1212 map.is_identical_to(isolate()->sloppy_function_without_prototype_map()) || |
1213 map.is_identical_to( | 1213 map.is_identical_to( |
1214 isolate()->sloppy_function_with_readonly_prototype_map()) || | 1214 isolate()->sloppy_function_with_readonly_prototype_map()) || |
1215 map.is_identical_to(isolate()->strict_function_map()))); | 1215 map.is_identical_to(isolate()->strict_function_map()) || |
| 1216 map.is_identical_to(isolate()->proxy_function_map())); |
1216 return NewFunction(map, info, context); | 1217 return NewFunction(map, info, context); |
1217 } | 1218 } |
1218 | 1219 |
1219 | 1220 |
1220 Handle<JSFunction> Factory::NewFunction(Handle<String> name) { | 1221 Handle<JSFunction> Factory::NewFunction(Handle<String> name) { |
1221 return NewFunction( | 1222 return NewFunction( |
1222 isolate()->sloppy_function_map(), name, MaybeHandle<Code>()); | 1223 isolate()->sloppy_function_map(), name, MaybeHandle<Code>()); |
1223 } | 1224 } |
1224 | 1225 |
1225 | 1226 |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1934 size_t byte_length) { | 1935 size_t byte_length) { |
1935 Handle<JSDataView> obj = NewJSDataView(); | 1936 Handle<JSDataView> obj = NewJSDataView(); |
1936 SetupArrayBufferView(isolate(), obj, buffer, byte_offset, byte_length); | 1937 SetupArrayBufferView(isolate(), obj, buffer, byte_offset, byte_length); |
1937 return obj; | 1938 return obj; |
1938 } | 1939 } |
1939 | 1940 |
1940 | 1941 |
1941 Handle<JSProxy> Factory::NewJSProxy(Handle<JSReceiver> target, | 1942 Handle<JSProxy> Factory::NewJSProxy(Handle<JSReceiver> target, |
1942 Handle<JSReceiver> handler) { | 1943 Handle<JSReceiver> handler) { |
1943 // Allocate the proxy object. | 1944 // Allocate the proxy object. |
1944 Handle<Map> map(isolate()->proxy_function()->initial_map()); | 1945 Handle<Map> map; |
| 1946 if (target->IsCallable()) { |
| 1947 if (target->IsConstructor()) { |
| 1948 map = Handle<Map>(isolate()->proxy_constructor_map()); |
| 1949 } else { |
| 1950 map = Handle<Map>(isolate()->proxy_callable_map()); |
| 1951 } |
| 1952 } else { |
| 1953 map = Handle<Map>(isolate()->proxy_map()); |
| 1954 } |
1945 DCHECK(map->prototype()->IsNull()); | 1955 DCHECK(map->prototype()->IsNull()); |
1946 Handle<JSProxy> result = New<JSProxy>(map, NEW_SPACE); | 1956 Handle<JSProxy> result = New<JSProxy>(map, NEW_SPACE); |
1947 result->set_target(*target); | 1957 result->set_target(*target); |
1948 result->set_handler(*handler); | 1958 result->set_handler(*handler); |
1949 result->set_hash(*undefined_value(), SKIP_WRITE_BARRIER); | 1959 result->set_hash(*undefined_value(), SKIP_WRITE_BARRIER); |
1950 return result; | 1960 return result; |
1951 } | 1961 } |
1952 | 1962 |
1953 | 1963 |
1954 Handle<JSGlobalProxy> Factory::NewUninitializedJSGlobalProxy() { | 1964 Handle<JSGlobalProxy> Factory::NewUninitializedJSGlobalProxy() { |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2309 } | 2319 } |
2310 | 2320 |
2311 | 2321 |
2312 Handle<Object> Factory::ToBoolean(bool value) { | 2322 Handle<Object> Factory::ToBoolean(bool value) { |
2313 return value ? true_value() : false_value(); | 2323 return value ? true_value() : false_value(); |
2314 } | 2324 } |
2315 | 2325 |
2316 | 2326 |
2317 } // namespace internal | 2327 } // namespace internal |
2318 } // namespace v8 | 2328 } // namespace v8 |
OLD | NEW |