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 1933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1944 Handle<Map> map(isolate()->proxy_function()->initial_map()); | 1944 Handle<Map> map(isolate()->proxy_function()->initial_map()); |
1945 DCHECK(map->prototype()->IsNull()); | 1945 DCHECK(map->prototype()->IsNull()); |
1946 Handle<JSProxy> result = New<JSProxy>(map, NEW_SPACE); | 1946 Handle<JSProxy> result = New<JSProxy>(map, NEW_SPACE); |
1947 result->set_target(*target); | 1947 result->set_target(*target); |
1948 result->set_handler(*handler); | 1948 result->set_handler(*handler); |
1949 result->set_hash(*undefined_value(), SKIP_WRITE_BARRIER); | 1949 result->set_hash(*undefined_value(), SKIP_WRITE_BARRIER); |
1950 return result; | 1950 return result; |
1951 } | 1951 } |
1952 | 1952 |
1953 | 1953 |
1954 Handle<JSProxy> Factory::NewJSFunctionProxy(Handle<JSReceiver> target, | |
1955 Handle<JSReceiver> handler, | |
1956 Handle<JSReceiver> call_trap, | |
1957 Handle<Object> construct_trap, | |
1958 Handle<Object> prototype) { | |
1959 // Allocate map. | |
1960 // TODO(rossberg): Once we optimize proxies, think about a scheme to share | |
1961 // maps. Will probably depend on the identity of the handler object, too. | |
1962 Handle<Map> map = NewMap(JS_FUNCTION_PROXY_TYPE, JSFunctionProxy::kSize); | |
1963 Map::SetPrototype(map, prototype); | |
1964 map->set_is_callable(); | |
1965 map->set_is_constructor(construct_trap->IsCallable()); | |
1966 | |
1967 // Allocate the proxy object. | |
1968 Handle<JSFunctionProxy> result = New<JSFunctionProxy>(map, NEW_SPACE); | |
1969 result->set_target(*target); | |
1970 result->set_handler(*handler); | |
1971 result->set_hash(*undefined_value(), SKIP_WRITE_BARRIER); | |
1972 result->set_call_trap(*call_trap); | |
1973 result->set_construct_trap(*construct_trap); | |
1974 return result; | |
1975 } | |
1976 | |
1977 | |
1978 Handle<JSGlobalProxy> Factory::NewUninitializedJSGlobalProxy() { | 1954 Handle<JSGlobalProxy> Factory::NewUninitializedJSGlobalProxy() { |
1979 // Create an empty shell of a JSGlobalProxy that needs to be reinitialized | 1955 // Create an empty shell of a JSGlobalProxy that needs to be reinitialized |
1980 // via ReinitializeJSGlobalProxy later. | 1956 // via ReinitializeJSGlobalProxy later. |
1981 Handle<Map> map = NewMap(JS_GLOBAL_PROXY_TYPE, JSGlobalProxy::kSize); | 1957 Handle<Map> map = NewMap(JS_GLOBAL_PROXY_TYPE, JSGlobalProxy::kSize); |
1982 // Maintain invariant expected from any JSGlobalProxy. | 1958 // Maintain invariant expected from any JSGlobalProxy. |
1983 map->set_is_access_check_needed(true); | 1959 map->set_is_access_check_needed(true); |
1984 CALL_HEAP_FUNCTION( | 1960 CALL_HEAP_FUNCTION( |
1985 isolate(), isolate()->heap()->AllocateJSObjectFromMap(*map, NOT_TENURED), | 1961 isolate(), isolate()->heap()->AllocateJSObjectFromMap(*map, NOT_TENURED), |
1986 JSGlobalProxy); | 1962 JSGlobalProxy); |
1987 } | 1963 } |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2333 } | 2309 } |
2334 | 2310 |
2335 | 2311 |
2336 Handle<Object> Factory::ToBoolean(bool value) { | 2312 Handle<Object> Factory::ToBoolean(bool value) { |
2337 return value ? true_value() : false_value(); | 2313 return value ? true_value() : false_value(); |
2338 } | 2314 } |
2339 | 2315 |
2340 | 2316 |
2341 } // namespace internal | 2317 } // namespace internal |
2342 } // namespace v8 | 2318 } // namespace v8 |
OLD | NEW |