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

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: Created 6 years, 4 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
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/conversions.h" 8 #include "src/conversions.h"
9 #include "src/isolate-inl.h" 9 #include "src/isolate-inl.h"
10 #include "src/macro-assembler.h" 10 #include "src/macro-assembler.h"
(...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 Handle<SharedFunctionInfo> info, 1224 Handle<SharedFunctionInfo> info,
1225 Handle<Context> context) { 1225 Handle<Context> context) {
1226 function->initialize_properties(); 1226 function->initialize_properties();
1227 function->initialize_elements(); 1227 function->initialize_elements();
1228 function->set_shared(*info); 1228 function->set_shared(*info);
1229 function->set_code(info->code()); 1229 function->set_code(info->code());
1230 function->set_context(*context); 1230 function->set_context(*context);
1231 function->set_prototype_or_initial_map(*the_hole_value()); 1231 function->set_prototype_or_initial_map(*the_hole_value());
1232 function->set_literals_or_bindings(*empty_fixed_array()); 1232 function->set_literals_or_bindings(*empty_fixed_array());
1233 function->set_next_function_link(*undefined_value()); 1233 function->set_next_function_link(*undefined_value());
1234
1235 // TODO(arv): This does not look correct. We need to make sure we use
1236 // a Map that has no prototype property.
1234 if (info->is_arrow()) function->RemovePrototype(); 1237 if (info->is_arrow()) function->RemovePrototype();
1235 } 1238 }
1236 1239
1237 1240
1238 Handle<JSFunction> Factory::NewFunction(Handle<Map> map, 1241 Handle<JSFunction> Factory::NewFunction(Handle<Map> map,
1239 Handle<SharedFunctionInfo> info, 1242 Handle<SharedFunctionInfo> info,
1240 Handle<Context> context, 1243 Handle<Context> context,
1241 PretenureFlag pretenure) { 1244 PretenureFlag pretenure) {
1242 AllocationSpace space = pretenure == TENURED ? OLD_POINTER_SPACE : NEW_SPACE; 1245 AllocationSpace space = pretenure == TENURED ? OLD_POINTER_SPACE : NEW_SPACE;
1243 Handle<JSFunction> result = New<JSFunction>(map, space); 1246 Handle<JSFunction> result = New<JSFunction>(map, space);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 } 1346 }
1344 1347
1345 return prototype; 1348 return prototype;
1346 } 1349 }
1347 1350
1348 1351
1349 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( 1352 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo(
1350 Handle<SharedFunctionInfo> info, 1353 Handle<SharedFunctionInfo> info,
1351 Handle<Context> context, 1354 Handle<Context> context,
1352 PretenureFlag pretenure) { 1355 PretenureFlag pretenure) {
1353 int map_index = Context::FunctionMapIndex(info->strict_mode(), 1356 int map_index = Context::FunctionMapIndex(info->strict_mode(), info->kind());
1354 info->is_generator());
1355 Handle<Map> map(Map::cast(context->native_context()->get(map_index))); 1357 Handle<Map> map(Map::cast(context->native_context()->get(map_index)));
1356 Handle<JSFunction> result = NewFunction(map, info, context, pretenure); 1358 Handle<JSFunction> result = NewFunction(map, info, context, pretenure);
1357 1359
1358 if (info->ic_age() != isolate()->heap()->global_ic_age()) { 1360 if (info->ic_age() != isolate()->heap()->global_ic_age()) {
1359 info->ResetForNewContext(isolate()->heap()->global_ic_age()); 1361 info->ResetForNewContext(isolate()->heap()->global_ic_age());
1360 } 1362 }
1361 1363
1362 int index = info->SearchOptimizedCodeMap(context->native_context(), 1364 int index = info->SearchOptimizedCodeMap(context->native_context(),
1363 BailoutId::None()); 1365 BailoutId::None());
1364 if (!info->bound() && index < 0) { 1366 if (!info->bound() && index < 0) {
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
1885 isolate(), 1887 isolate(),
1886 isolate()->heap()->AllocateFixedArrayWithFiller( 1888 isolate()->heap()->AllocateFixedArrayWithFiller(
1887 slot_count, 1889 slot_count,
1888 TENURED, 1890 TENURED,
1889 *TypeFeedbackInfo::UninitializedSentinel(isolate())), 1891 *TypeFeedbackInfo::UninitializedSentinel(isolate())),
1890 FixedArray); 1892 FixedArray);
1891 } 1893 }
1892 1894
1893 1895
1894 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( 1896 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo(
1895 Handle<String> name, int number_of_literals, bool is_generator, 1897 Handle<String> name, int number_of_literals, FunctionKind kind,
1896 bool is_arrow, Handle<Code> code, Handle<ScopeInfo> scope_info, 1898 Handle<Code> code, Handle<ScopeInfo> scope_info,
1897 Handle<FixedArray> feedback_vector) { 1899 Handle<FixedArray> feedback_vector) {
1898 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name, code); 1900 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name, code);
1899 shared->set_scope_info(*scope_info); 1901 shared->set_scope_info(*scope_info);
1900 shared->set_feedback_vector(*feedback_vector); 1902 shared->set_feedback_vector(*feedback_vector);
1901 shared->set_is_arrow(is_arrow); 1903 shared->set_kind(kind);
1902 int literals_array_size = number_of_literals; 1904 int literals_array_size = number_of_literals;
1903 // If the function contains object, regexp or array literals, 1905 // If the function contains object, regexp or array literals,
1904 // allocate extra space for a literals array prefix containing the 1906 // allocate extra space for a literals array prefix containing the
1905 // context. 1907 // context.
1906 if (number_of_literals > 0) { 1908 if (number_of_literals > 0) {
1907 literals_array_size += JSFunction::kLiteralsPrefixSize; 1909 literals_array_size += JSFunction::kLiteralsPrefixSize;
1908 } 1910 }
1909 shared->set_num_literals(literals_array_size); 1911 shared->set_num_literals(literals_array_size);
1910 if (is_generator) { 1912 if (IsGeneratorFunction(kind)) {
1911 shared->set_instance_class_name(isolate()->heap()->Generator_string()); 1913 shared->set_instance_class_name(isolate()->heap()->Generator_string());
1912 shared->DisableOptimization(kGenerator); 1914 shared->DisableOptimization(kGenerator);
1913 } 1915 }
1914 return shared; 1916 return shared;
1915 } 1917 }
1916 1918
1917 1919
1918 Handle<JSMessageObject> Factory::NewJSMessageObject( 1920 Handle<JSMessageObject> Factory::NewJSMessageObject(
1919 Handle<String> type, 1921 Handle<String> type,
1920 Handle<JSArray> arguments, 1922 Handle<JSArray> arguments,
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
2379 return Handle<Object>::null(); 2381 return Handle<Object>::null();
2380 } 2382 }
2381 2383
2382 2384
2383 Handle<Object> Factory::ToBoolean(bool value) { 2385 Handle<Object> Factory::ToBoolean(bool value) {
2384 return value ? true_value() : false_value(); 2386 return value ? true_value() : false_value();
2385 } 2387 }
2386 2388
2387 2389
2388 } } // namespace v8::internal 2390 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698