Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(461)

Side by Side Diff: src/factory.cc

Issue 1871503002: Lazily compute boundfunction .name and .length if possible (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/builtins.cc ('k') | src/objects.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1942 matching lines...) Expand 10 before | Expand all | Expand 10 after
1953 if (bound_args.length() == 0) { 1953 if (bound_args.length() == 0) {
1954 bound_arguments = empty_fixed_array(); 1954 bound_arguments = empty_fixed_array();
1955 } else { 1955 } else {
1956 bound_arguments = NewFixedArray(bound_args.length()); 1956 bound_arguments = NewFixedArray(bound_args.length());
1957 for (int i = 0; i < bound_args.length(); ++i) { 1957 for (int i = 0; i < bound_args.length(); ++i) {
1958 bound_arguments->set(i, *bound_args[i]); 1958 bound_arguments->set(i, *bound_args[i]);
1959 } 1959 }
1960 } 1960 }
1961 1961
1962 // Setup the map for the JSBoundFunction instance. 1962 // Setup the map for the JSBoundFunction instance.
1963 Handle<Map> map = handle( 1963 Handle<Map> map = target_function->IsConstructor()
1964 target_function->IsConstructor() 1964 ? isolate()->bound_function_with_constructor_map()
1965 ? isolate()->native_context()->bound_function_with_constructor_map() 1965 : isolate()->bound_function_without_constructor_map();
1966 : isolate()
1967 ->native_context()
1968 ->bound_function_without_constructor_map(),
1969 isolate());
1970 if (map->prototype() != *prototype) { 1966 if (map->prototype() != *prototype) {
1971 map = Map::TransitionToPrototype(map, prototype, REGULAR_PROTOTYPE); 1967 map = Map::TransitionToPrototype(map, prototype, REGULAR_PROTOTYPE);
1972 } 1968 }
1973 DCHECK_EQ(target_function->IsConstructor(), map->is_constructor()); 1969 DCHECK_EQ(target_function->IsConstructor(), map->is_constructor());
1974 1970
1975 // Setup the JSBoundFunction instance. 1971 // Setup the JSBoundFunction instance.
1976 Handle<JSBoundFunction> result = 1972 Handle<JSBoundFunction> result =
1977 Handle<JSBoundFunction>::cast(NewJSObjectFromMap(map)); 1973 Handle<JSBoundFunction>::cast(NewJSObjectFromMap(map));
1978 result->set_bound_target_function(*target_function); 1974 result->set_bound_target_function(*target_function);
1979 result->set_bound_this(*bound_this); 1975 result->set_bound_this(*bound_this);
1980 result->set_bound_arguments(*bound_arguments); 1976 result->set_bound_arguments(*bound_arguments);
1981 result->set_length(Smi::FromInt(0));
1982 result->set_name(*undefined_value(), SKIP_WRITE_BARRIER);
1983 return result; 1977 return result;
1984 } 1978 }
1985 1979
1986 1980
1987 // ES6 section 9.5.15 ProxyCreate (target, handler) 1981 // ES6 section 9.5.15 ProxyCreate (target, handler)
1988 Handle<JSProxy> Factory::NewJSProxy(Handle<JSReceiver> target, 1982 Handle<JSProxy> Factory::NewJSProxy(Handle<JSReceiver> target,
1989 Handle<JSReceiver> handler) { 1983 Handle<JSReceiver> handler) {
1990 // Allocate the proxy object. 1984 // Allocate the proxy object.
1991 Handle<Map> map; 1985 Handle<Map> map;
1992 if (target->IsCallable()) { 1986 if (target->IsCallable()) {
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
2377 } 2371 }
2378 2372
2379 2373
2380 Handle<Object> Factory::ToBoolean(bool value) { 2374 Handle<Object> Factory::ToBoolean(bool value) {
2381 return value ? true_value() : false_value(); 2375 return value ? true_value() : false_value();
2382 } 2376 }
2383 2377
2384 2378
2385 } // namespace internal 2379 } // namespace internal
2386 } // namespace v8 2380 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698