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

Side by Side Diff: src/factory.cc

Issue 477263002: ES6: Add support for method shorthand in object literals (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: merge Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « src/factory.h ('k') | src/flag-definitions.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/conversions.h" 9 #include "src/conversions.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1230 Handle<SharedFunctionInfo> info, 1230 Handle<SharedFunctionInfo> info,
1231 Handle<Context> context) { 1231 Handle<Context> context) {
1232 function->initialize_properties(); 1232 function->initialize_properties();
1233 function->initialize_elements(); 1233 function->initialize_elements();
1234 function->set_shared(*info); 1234 function->set_shared(*info);
1235 function->set_code(info->code()); 1235 function->set_code(info->code());
1236 function->set_context(*context); 1236 function->set_context(*context);
1237 function->set_prototype_or_initial_map(*the_hole_value()); 1237 function->set_prototype_or_initial_map(*the_hole_value());
1238 function->set_literals_or_bindings(*empty_fixed_array()); 1238 function->set_literals_or_bindings(*empty_fixed_array());
1239 function->set_next_function_link(*undefined_value()); 1239 function->set_next_function_link(*undefined_value());
1240
1241 // TODO(arv): This does not look correct. We need to make sure we use
1242 // a Map that has no prototype property.
1240 if (info->is_arrow()) function->RemovePrototype(); 1243 if (info->is_arrow()) function->RemovePrototype();
1241 } 1244 }
1242 1245
1243 1246
1244 Handle<JSFunction> Factory::NewFunction(Handle<Map> map, 1247 Handle<JSFunction> Factory::NewFunction(Handle<Map> map,
1245 Handle<SharedFunctionInfo> info, 1248 Handle<SharedFunctionInfo> info,
1246 Handle<Context> context, 1249 Handle<Context> context,
1247 PretenureFlag pretenure) { 1250 PretenureFlag pretenure) {
1248 AllocationSpace space = pretenure == TENURED ? OLD_POINTER_SPACE : NEW_SPACE; 1251 AllocationSpace space = pretenure == TENURED ? OLD_POINTER_SPACE : NEW_SPACE;
1249 Handle<JSFunction> result = New<JSFunction>(map, space); 1252 Handle<JSFunction> result = New<JSFunction>(map, space);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 } 1352 }
1350 1353
1351 return prototype; 1354 return prototype;
1352 } 1355 }
1353 1356
1354 1357
1355 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( 1358 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo(
1356 Handle<SharedFunctionInfo> info, 1359 Handle<SharedFunctionInfo> info,
1357 Handle<Context> context, 1360 Handle<Context> context,
1358 PretenureFlag pretenure) { 1361 PretenureFlag pretenure) {
1359 int map_index = Context::FunctionMapIndex(info->strict_mode(), 1362 int map_index = Context::FunctionMapIndex(info->strict_mode(), info->kind());
1360 info->is_generator());
1361 Handle<Map> map(Map::cast(context->native_context()->get(map_index))); 1363 Handle<Map> map(Map::cast(context->native_context()->get(map_index)));
1362 Handle<JSFunction> result = NewFunction(map, info, context, pretenure); 1364 Handle<JSFunction> result = NewFunction(map, info, context, pretenure);
1363 1365
1364 if (info->ic_age() != isolate()->heap()->global_ic_age()) { 1366 if (info->ic_age() != isolate()->heap()->global_ic_age()) {
1365 info->ResetForNewContext(isolate()->heap()->global_ic_age()); 1367 info->ResetForNewContext(isolate()->heap()->global_ic_age());
1366 } 1368 }
1367 1369
1368 int index = info->SearchOptimizedCodeMap(context->native_context(), 1370 int index = info->SearchOptimizedCodeMap(context->native_context(),
1369 BailoutId::None()); 1371 BailoutId::None());
1370 if (!info->bound() && index < 0) { 1372 if (!info->bound() && index < 0) {
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
1897 isolate(), 1899 isolate(),
1898 isolate()->heap()->AllocateFixedArrayWithFiller( 1900 isolate()->heap()->AllocateFixedArrayWithFiller(
1899 slot_count, 1901 slot_count,
1900 TENURED, 1902 TENURED,
1901 *TypeFeedbackInfo::UninitializedSentinel(isolate())), 1903 *TypeFeedbackInfo::UninitializedSentinel(isolate())),
1902 FixedArray); 1904 FixedArray);
1903 } 1905 }
1904 1906
1905 1907
1906 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( 1908 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo(
1907 Handle<String> name, int number_of_literals, bool is_generator, 1909 Handle<String> name, int number_of_literals, FunctionKind kind,
1908 bool is_arrow, Handle<Code> code, Handle<ScopeInfo> scope_info, 1910 Handle<Code> code, Handle<ScopeInfo> scope_info,
1909 Handle<FixedArray> feedback_vector) { 1911 Handle<FixedArray> feedback_vector) {
1912 DCHECK(IsValidFunctionKind(kind));
1910 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name, code); 1913 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name, code);
1911 shared->set_scope_info(*scope_info); 1914 shared->set_scope_info(*scope_info);
1912 shared->set_feedback_vector(*feedback_vector); 1915 shared->set_feedback_vector(*feedback_vector);
1913 shared->set_is_arrow(is_arrow); 1916 shared->set_kind(kind);
1914 int literals_array_size = number_of_literals; 1917 int literals_array_size = number_of_literals;
1915 // If the function contains object, regexp or array literals, 1918 // If the function contains object, regexp or array literals,
1916 // allocate extra space for a literals array prefix containing the 1919 // allocate extra space for a literals array prefix containing the
1917 // context. 1920 // context.
1918 if (number_of_literals > 0) { 1921 if (number_of_literals > 0) {
1919 literals_array_size += JSFunction::kLiteralsPrefixSize; 1922 literals_array_size += JSFunction::kLiteralsPrefixSize;
1920 } 1923 }
1921 shared->set_num_literals(literals_array_size); 1924 shared->set_num_literals(literals_array_size);
1922 if (is_generator) { 1925 if (IsGeneratorFunction(kind)) {
1923 shared->set_instance_class_name(isolate()->heap()->Generator_string()); 1926 shared->set_instance_class_name(isolate()->heap()->Generator_string());
1924 shared->DisableOptimization(kGenerator); 1927 shared->DisableOptimization(kGenerator);
1925 } 1928 }
1926 return shared; 1929 return shared;
1927 } 1930 }
1928 1931
1929 1932
1930 Handle<JSMessageObject> Factory::NewJSMessageObject( 1933 Handle<JSMessageObject> Factory::NewJSMessageObject(
1931 Handle<String> type, 1934 Handle<String> type,
1932 Handle<JSArray> arguments, 1935 Handle<JSArray> arguments,
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
2392 return Handle<Object>::null(); 2395 return Handle<Object>::null();
2393 } 2396 }
2394 2397
2395 2398
2396 Handle<Object> Factory::ToBoolean(bool value) { 2399 Handle<Object> Factory::ToBoolean(bool value) {
2397 return value ? true_value() : false_value(); 2400 return value ? true_value() : false_value();
2398 } 2401 }
2399 2402
2400 2403
2401 } } // namespace v8::internal 2404 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/factory.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698