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