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 1926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1937 Handle<Map> map(isolate()->proxy_function()->initial_map()); | 1937 Handle<Map> map(isolate()->proxy_function()->initial_map()); |
1938 DCHECK(map->prototype()->IsNull()); | 1938 DCHECK(map->prototype()->IsNull()); |
1939 Handle<JSProxy> result = New<JSProxy>(map, NEW_SPACE); | 1939 Handle<JSProxy> result = New<JSProxy>(map, NEW_SPACE); |
1940 result->set_target(*target); | 1940 result->set_target(*target); |
1941 result->set_handler(*handler); | 1941 result->set_handler(*handler); |
1942 result->set_hash(*undefined_value(), SKIP_WRITE_BARRIER); | 1942 result->set_hash(*undefined_value(), SKIP_WRITE_BARRIER); |
1943 return result; | 1943 return result; |
1944 } | 1944 } |
1945 | 1945 |
1946 | 1946 |
1947 Handle<JSProxy> Factory::NewJSFunctionProxy(Handle<JSReceiver> target, | |
1948 Handle<JSReceiver> handler, | |
1949 Handle<JSReceiver> call_trap, | |
1950 Handle<Object> construct_trap, | |
1951 Handle<Object> prototype) { | |
1952 // Allocate map. | |
1953 // TODO(rossberg): Once we optimize proxies, think about a scheme to share | |
1954 // maps. Will probably depend on the identity of the handler object, too. | |
1955 Handle<Map> map = NewMap(JS_FUNCTION_PROXY_TYPE, JSFunctionProxy::kSize); | |
1956 Map::SetPrototype(map, prototype); | |
1957 map->set_is_callable(); | |
1958 map->set_is_constructor(construct_trap->IsCallable()); | |
1959 | |
1960 // Allocate the proxy object. | |
1961 Handle<JSFunctionProxy> result = New<JSFunctionProxy>(map, NEW_SPACE); | |
1962 result->set_target(*target); | |
1963 result->set_handler(*handler); | |
1964 result->set_hash(*undefined_value(), SKIP_WRITE_BARRIER); | |
1965 result->set_call_trap(*call_trap); | |
1966 result->set_construct_trap(*construct_trap); | |
1967 return result; | |
1968 } | |
1969 | |
1970 | |
1971 Handle<JSGlobalProxy> Factory::NewUninitializedJSGlobalProxy() { | 1947 Handle<JSGlobalProxy> Factory::NewUninitializedJSGlobalProxy() { |
1972 // Create an empty shell of a JSGlobalProxy that needs to be reinitialized | 1948 // Create an empty shell of a JSGlobalProxy that needs to be reinitialized |
1973 // via ReinitializeJSGlobalProxy later. | 1949 // via ReinitializeJSGlobalProxy later. |
1974 Handle<Map> map = NewMap(JS_GLOBAL_PROXY_TYPE, JSGlobalProxy::kSize); | 1950 Handle<Map> map = NewMap(JS_GLOBAL_PROXY_TYPE, JSGlobalProxy::kSize); |
1975 // Maintain invariant expected from any JSGlobalProxy. | 1951 // Maintain invariant expected from any JSGlobalProxy. |
1976 map->set_is_access_check_needed(true); | 1952 map->set_is_access_check_needed(true); |
1977 CALL_HEAP_FUNCTION( | 1953 CALL_HEAP_FUNCTION( |
1978 isolate(), isolate()->heap()->AllocateJSObjectFromMap(*map, NOT_TENURED), | 1954 isolate(), isolate()->heap()->AllocateJSObjectFromMap(*map, NOT_TENURED), |
1979 JSGlobalProxy); | 1955 JSGlobalProxy); |
1980 } | 1956 } |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2326 } | 2302 } |
2327 | 2303 |
2328 | 2304 |
2329 Handle<Object> Factory::ToBoolean(bool value) { | 2305 Handle<Object> Factory::ToBoolean(bool value) { |
2330 return value ? true_value() : false_value(); | 2306 return value ? true_value() : false_value(); |
2331 } | 2307 } |
2332 | 2308 |
2333 | 2309 |
2334 } // namespace internal | 2310 } // namespace internal |
2335 } // namespace v8 | 2311 } // namespace v8 |
OLD | NEW |