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

Side by Side Diff: src/bootstrapper.cc

Issue 270573003: Rename NewFunction without prototype to NewFunctionWithoutPrototype (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Reverse argument order to be consistent Created 6 years, 7 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 | « no previous file | src/factory.h » ('j') | src/factory.cc » ('J')
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 "bootstrapper.h" 5 #include "bootstrapper.h"
6 6
7 #include "accessors.h" 7 #include "accessors.h"
8 #include "isolate-inl.h" 8 #include "isolate-inl.h"
9 #include "natives.h" 9 #include "natives.h"
10 #include "snapshot.h" 10 #include "snapshot.h"
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 InstanceType type, 351 InstanceType type,
352 int instance_size, 352 int instance_size,
353 MaybeHandle<JSObject> maybe_prototype, 353 MaybeHandle<JSObject> maybe_prototype,
354 Builtins::Name call) { 354 Builtins::Name call) {
355 Isolate* isolate = target->GetIsolate(); 355 Isolate* isolate = target->GetIsolate();
356 Factory* factory = isolate->factory(); 356 Factory* factory = isolate->factory();
357 Handle<String> internalized_name = factory->InternalizeUtf8String(name); 357 Handle<String> internalized_name = factory->InternalizeUtf8String(name);
358 Handle<Code> call_code = Handle<Code>(isolate->builtins()->builtin(call)); 358 Handle<Code> call_code = Handle<Code>(isolate->builtins()->builtin(call));
359 Handle<JSObject> prototype; 359 Handle<JSObject> prototype;
360 Handle<JSFunction> function = maybe_prototype.ToHandle(&prototype) 360 Handle<JSFunction> function = maybe_prototype.ToHandle(&prototype)
361 ? factory->NewFunction(prototype, internalized_name, type, 361 ? factory->NewFunction(internalized_name, call_code, prototype,
362 instance_size, call_code) 362 type, instance_size)
363 : factory->NewFunction(internalized_name, call_code); 363 : factory->NewFunctionWithoutPrototype(internalized_name, call_code);
364 PropertyAttributes attributes; 364 PropertyAttributes attributes;
365 if (target->IsJSBuiltinsObject()) { 365 if (target->IsJSBuiltinsObject()) {
366 attributes = 366 attributes =
367 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 367 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
368 } else { 368 } else {
369 attributes = DONT_ENUM; 369 attributes = DONT_ENUM;
370 } 370 }
371 JSObject::SetLocalPropertyIgnoreAttributes( 371 JSObject::SetLocalPropertyIgnoreAttributes(
372 target, internalized_name, function, attributes).Check(); 372 target, internalized_name, function, attributes).Check();
373 if (target->IsJSGlobalObject()) { 373 if (target->IsJSGlobalObject()) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 // assertions during startup. 481 // assertions during startup.
482 native_context()->set_initial_array_prototype(*prototype); 482 native_context()->set_initial_array_prototype(*prototype);
483 Accessors::FunctionSetPrototype(object_fun, prototype); 483 Accessors::FunctionSetPrototype(object_fun, prototype);
484 } 484 }
485 485
486 // Allocate the empty function as the prototype for function ECMAScript 486 // Allocate the empty function as the prototype for function ECMAScript
487 // 262 15.3.4. 487 // 262 15.3.4.
488 Handle<String> empty_string = 488 Handle<String> empty_string =
489 factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("Empty")); 489 factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("Empty"));
490 Handle<Code> code(isolate->builtins()->builtin(Builtins::kEmptyFunction)); 490 Handle<Code> code(isolate->builtins()->builtin(Builtins::kEmptyFunction));
491 Handle<JSFunction> empty_function = factory->NewFunction(empty_string, code); 491 Handle<JSFunction> empty_function = factory->NewFunctionWithoutPrototype(
492 empty_string, code);
492 493
493 // --- E m p t y --- 494 // --- E m p t y ---
494 Handle<String> source = factory->NewStringFromStaticAscii("() {}"); 495 Handle<String> source = factory->NewStringFromStaticAscii("() {}");
495 Handle<Script> script = factory->NewScript(source); 496 Handle<Script> script = factory->NewScript(source);
496 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); 497 script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
497 empty_function->shared()->set_script(*script); 498 empty_function->shared()->set_script(*script);
498 empty_function->shared()->set_start_position(0); 499 empty_function->shared()->set_start_position(0);
499 empty_function->shared()->set_end_position(source->length()); 500 empty_function->shared()->set_end_position(source->length());
500 empty_function->shared()->DontAdaptArguments(); 501 empty_function->shared()->DontAdaptArguments();
501 502
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 } 563 }
563 564
564 565
565 // ECMAScript 5th Edition, 13.2.3 566 // ECMAScript 5th Edition, 13.2.3
566 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() { 567 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() {
567 if (throw_type_error_function.is_null()) { 568 if (throw_type_error_function.is_null()) {
568 Handle<String> name = factory()->InternalizeOneByteString( 569 Handle<String> name = factory()->InternalizeOneByteString(
569 STATIC_ASCII_VECTOR("ThrowTypeError")); 570 STATIC_ASCII_VECTOR("ThrowTypeError"));
570 Handle<Code> code(isolate()->builtins()->builtin( 571 Handle<Code> code(isolate()->builtins()->builtin(
571 Builtins::kStrictModePoisonPill)); 572 Builtins::kStrictModePoisonPill));
572 throw_type_error_function = factory()->NewFunction(name, code); 573 throw_type_error_function = factory()->NewFunctionWithoutPrototype(
574 name, code);
573 throw_type_error_function->set_map(native_context()->sloppy_function_map()); 575 throw_type_error_function->set_map(native_context()->sloppy_function_map());
574 throw_type_error_function->shared()->DontAdaptArguments(); 576 throw_type_error_function->shared()->DontAdaptArguments();
575 577
576 JSObject::PreventExtensions(throw_type_error_function).Assert(); 578 JSObject::PreventExtensions(throw_type_error_function).Assert();
577 } 579 }
578 return throw_type_error_function; 580 return throw_type_error_function;
579 } 581 }
580 582
581 583
582 Handle<Map> Genesis::CreateStrictFunctionMap( 584 Handle<Map> Genesis::CreateStrictFunctionMap(
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 js_global_template = 703 js_global_template =
702 Handle<ObjectTemplateInfo>::cast(proto_template); 704 Handle<ObjectTemplateInfo>::cast(proto_template);
703 } 705 }
704 } 706 }
705 707
706 if (js_global_template.is_null()) { 708 if (js_global_template.is_null()) {
707 Handle<String> name = Handle<String>(heap()->empty_string()); 709 Handle<String> name = Handle<String>(heap()->empty_string());
708 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin( 710 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin(
709 Builtins::kIllegal)); 711 Builtins::kIllegal));
710 js_global_function = factory()->NewFunction( 712 js_global_function = factory()->NewFunction(
711 name, JS_GLOBAL_OBJECT_TYPE, JSGlobalObject::kSize, code); 713 name, code, JS_GLOBAL_OBJECT_TYPE, JSGlobalObject::kSize);
712 // Change the constructor property of the prototype of the 714 // Change the constructor property of the prototype of the
713 // hidden global function to refer to the Object function. 715 // hidden global function to refer to the Object function.
714 Handle<JSObject> prototype = 716 Handle<JSObject> prototype =
715 Handle<JSObject>( 717 Handle<JSObject>(
716 JSObject::cast(js_global_function->instance_prototype())); 718 JSObject::cast(js_global_function->instance_prototype()));
717 JSObject::SetLocalPropertyIgnoreAttributes( 719 JSObject::SetLocalPropertyIgnoreAttributes(
718 prototype, factory()->constructor_string(), 720 prototype, factory()->constructor_string(),
719 isolate()->object_function(), NONE).Check(); 721 isolate()->object_function(), NONE).Check();
720 } else { 722 } else {
721 Handle<FunctionTemplateInfo> js_global_constructor( 723 Handle<FunctionTemplateInfo> js_global_constructor(
(...skipping 12 matching lines...) Expand all
734 *inner_global_out = inner_global; 736 *inner_global_out = inner_global;
735 } 737 }
736 738
737 // Step 2: create or re-initialize the global proxy object. 739 // Step 2: create or re-initialize the global proxy object.
738 Handle<JSFunction> global_proxy_function; 740 Handle<JSFunction> global_proxy_function;
739 if (global_template.IsEmpty()) { 741 if (global_template.IsEmpty()) {
740 Handle<String> name = Handle<String>(heap()->empty_string()); 742 Handle<String> name = Handle<String>(heap()->empty_string());
741 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin( 743 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin(
742 Builtins::kIllegal)); 744 Builtins::kIllegal));
743 global_proxy_function = factory()->NewFunction( 745 global_proxy_function = factory()->NewFunction(
744 name, JS_GLOBAL_PROXY_TYPE, JSGlobalProxy::kSize, code); 746 name, code, JS_GLOBAL_PROXY_TYPE, JSGlobalProxy::kSize);
745 } else { 747 } else {
746 Handle<ObjectTemplateInfo> data = 748 Handle<ObjectTemplateInfo> data =
747 v8::Utils::OpenHandle(*global_template); 749 v8::Utils::OpenHandle(*global_template);
748 Handle<FunctionTemplateInfo> global_constructor( 750 Handle<FunctionTemplateInfo> global_constructor(
749 FunctionTemplateInfo::cast(data->constructor())); 751 FunctionTemplateInfo::cast(data->constructor()));
750 global_proxy_function = 752 global_proxy_function =
751 factory()->CreateApiFunction(global_constructor, 753 factory()->CreateApiFunction(global_constructor,
752 factory()->the_hole_value(), 754 factory()->the_hole_value(),
753 factory()->OuterGlobalObject); 755 factory()->OuterGlobalObject);
754 } 756 }
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 } 1072 }
1071 1073
1072 { // --- arguments_boilerplate_ 1074 { // --- arguments_boilerplate_
1073 // Make sure we can recognize argument objects at runtime. 1075 // Make sure we can recognize argument objects at runtime.
1074 // This is done by introducing an anonymous function with 1076 // This is done by introducing an anonymous function with
1075 // class_name equals 'Arguments'. 1077 // class_name equals 'Arguments'.
1076 Handle<String> arguments_string = factory->InternalizeOneByteString( 1078 Handle<String> arguments_string = factory->InternalizeOneByteString(
1077 STATIC_ASCII_VECTOR("Arguments")); 1079 STATIC_ASCII_VECTOR("Arguments"));
1078 Handle<Code> code(isolate->builtins()->builtin(Builtins::kIllegal)); 1080 Handle<Code> code(isolate->builtins()->builtin(Builtins::kIllegal));
1079 1081
1080 Handle<JSFunction> function = factory->NewFunction(arguments_string, code); 1082 Handle<JSFunction> function = factory->NewFunctionWithoutPrototype(
1083 arguments_string, code);
1081 ASSERT(!function->has_initial_map()); 1084 ASSERT(!function->has_initial_map());
1082 function->shared()->set_instance_class_name(*arguments_string); 1085 function->shared()->set_instance_class_name(*arguments_string);
1083 function->shared()->set_expected_nof_properties(2); 1086 function->shared()->set_expected_nof_properties(2);
1084 function->set_prototype_or_initial_map( 1087 function->set_prototype_or_initial_map(
1085 native_context()->object_function()->prototype()); 1088 native_context()->object_function()->prototype());
1086 Handle<JSObject> result = factory->NewJSObject(function); 1089 Handle<JSObject> result = factory->NewJSObject(function);
1087 1090
1088 native_context()->set_sloppy_arguments_boilerplate(*result); 1091 native_context()->set_sloppy_arguments_boilerplate(*result);
1089 // Note: length must be added as the first property and 1092 // Note: length must be added as the first property and
1090 // callee must be added as the second property. 1093 // callee must be added as the second property.
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 ASSERT(result->HasFastProperties()); 1213 ASSERT(result->HasFastProperties());
1211 ASSERT(result->HasFastObjectElements()); 1214 ASSERT(result->HasFastObjectElements());
1212 #endif 1215 #endif
1213 } 1216 }
1214 1217
1215 { // --- context extension 1218 { // --- context extension
1216 // Create a function for the context extension objects. 1219 // Create a function for the context extension objects.
1217 Handle<Code> code = Handle<Code>( 1220 Handle<Code> code = Handle<Code>(
1218 isolate->builtins()->builtin(Builtins::kIllegal)); 1221 isolate->builtins()->builtin(Builtins::kIllegal));
1219 Handle<JSFunction> context_extension_fun = factory->NewFunction( 1222 Handle<JSFunction> context_extension_fun = factory->NewFunction(
1220 factory->empty_string(), JS_CONTEXT_EXTENSION_OBJECT_TYPE, 1223 factory->empty_string(), code, JS_CONTEXT_EXTENSION_OBJECT_TYPE,
1221 JSObject::kHeaderSize, code); 1224 JSObject::kHeaderSize);
1222 1225
1223 Handle<String> name = factory->InternalizeOneByteString( 1226 Handle<String> name = factory->InternalizeOneByteString(
1224 STATIC_ASCII_VECTOR("context_extension")); 1227 STATIC_ASCII_VECTOR("context_extension"));
1225 context_extension_fun->shared()->set_instance_class_name(*name); 1228 context_extension_fun->shared()->set_instance_class_name(*name);
1226 native_context()->set_context_extension_function(*context_extension_fun); 1229 native_context()->set_context_extension_function(*context_extension_fun);
1227 } 1230 }
1228 1231
1229 1232
1230 { 1233 {
1231 // Set up the call-as-function delegate. 1234 // Set up the call-as-function delegate.
1232 Handle<Code> code = 1235 Handle<Code> code =
1233 Handle<Code>(isolate->builtins()->builtin( 1236 Handle<Code>(isolate->builtins()->builtin(
1234 Builtins::kHandleApiCallAsFunction)); 1237 Builtins::kHandleApiCallAsFunction));
1235 Handle<JSFunction> delegate = factory->NewFunction( 1238 Handle<JSFunction> delegate = factory->NewFunction(
1236 factory->empty_string(), JS_OBJECT_TYPE, JSObject::kHeaderSize, code); 1239 factory->empty_string(), code, JS_OBJECT_TYPE, JSObject::kHeaderSize);
1237 native_context()->set_call_as_function_delegate(*delegate); 1240 native_context()->set_call_as_function_delegate(*delegate);
1238 delegate->shared()->DontAdaptArguments(); 1241 delegate->shared()->DontAdaptArguments();
1239 } 1242 }
1240 1243
1241 { 1244 {
1242 // Set up the call-as-constructor delegate. 1245 // Set up the call-as-constructor delegate.
1243 Handle<Code> code = 1246 Handle<Code> code =
1244 Handle<Code>(isolate->builtins()->builtin( 1247 Handle<Code>(isolate->builtins()->builtin(
1245 Builtins::kHandleApiCallAsConstructor)); 1248 Builtins::kHandleApiCallAsConstructor));
1246 Handle<JSFunction> delegate = factory->NewFunction( 1249 Handle<JSFunction> delegate = factory->NewFunction(
1247 factory->empty_string(), JS_OBJECT_TYPE, JSObject::kHeaderSize, code); 1250 factory->empty_string(), code, JS_OBJECT_TYPE, JSObject::kHeaderSize);
1248 native_context()->set_call_as_constructor_delegate(*delegate); 1251 native_context()->set_call_as_constructor_delegate(*delegate);
1249 delegate->shared()->DontAdaptArguments(); 1252 delegate->shared()->DontAdaptArguments();
1250 } 1253 }
1251 1254
1252 // Initialize the embedder data slot. 1255 // Initialize the embedder data slot.
1253 Handle<FixedArray> embedder_data = factory->NewFixedArray(3); 1256 Handle<FixedArray> embedder_data = factory->NewFixedArray(3);
1254 native_context()->set_embedder_data(*embedder_data); 1257 native_context()->set_embedder_data(*embedder_data);
1255 } 1258 }
1256 1259
1257 1260
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
1606 1609
1607 bool Genesis::InstallNatives() { 1610 bool Genesis::InstallNatives() {
1608 HandleScope scope(isolate()); 1611 HandleScope scope(isolate());
1609 1612
1610 // Create a function for the builtins object. Allocate space for the 1613 // Create a function for the builtins object. Allocate space for the
1611 // JavaScript builtins, a reference to the builtins object 1614 // JavaScript builtins, a reference to the builtins object
1612 // (itself) and a reference to the native_context directly in the object. 1615 // (itself) and a reference to the native_context directly in the object.
1613 Handle<Code> code = Handle<Code>( 1616 Handle<Code> code = Handle<Code>(
1614 isolate()->builtins()->builtin(Builtins::kIllegal)); 1617 isolate()->builtins()->builtin(Builtins::kIllegal));
1615 Handle<JSFunction> builtins_fun = factory()->NewFunction( 1618 Handle<JSFunction> builtins_fun = factory()->NewFunction(
1616 factory()->empty_string(), JS_BUILTINS_OBJECT_TYPE, 1619 factory()->empty_string(), code, JS_BUILTINS_OBJECT_TYPE,
1617 JSBuiltinsObject::kSize, code); 1620 JSBuiltinsObject::kSize);
1618 1621
1619 Handle<String> name = 1622 Handle<String> name =
1620 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("builtins")); 1623 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("builtins"));
1621 builtins_fun->shared()->set_instance_class_name(*name); 1624 builtins_fun->shared()->set_instance_class_name(*name);
1622 builtins_fun->initial_map()->set_dictionary_map(true); 1625 builtins_fun->initial_map()->set_dictionary_map(true);
1623 builtins_fun->initial_map()->set_prototype(heap()->null_value()); 1626 builtins_fun->initial_map()->set_prototype(heap()->null_value());
1624 1627
1625 // Allocate the builtins object. 1628 // Allocate the builtins object.
1626 Handle<JSBuiltinsObject> builtins = 1629 Handle<JSBuiltinsObject> builtins =
1627 Handle<JSBuiltinsObject>::cast(factory()->NewGlobalObject(builtins_fun)); 1630 Handle<JSBuiltinsObject>::cast(factory()->NewGlobalObject(builtins_fun));
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after
2653 return from + sizeof(NestingCounterType); 2656 return from + sizeof(NestingCounterType);
2654 } 2657 }
2655 2658
2656 2659
2657 // Called when the top-level V8 mutex is destroyed. 2660 // Called when the top-level V8 mutex is destroyed.
2658 void Bootstrapper::FreeThreadResources() { 2661 void Bootstrapper::FreeThreadResources() {
2659 ASSERT(!IsActive()); 2662 ASSERT(!IsActive());
2660 } 2663 }
2661 2664
2662 } } // namespace v8::internal 2665 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/factory.h » ('j') | src/factory.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698