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

Side by Side Diff: src/bootstrapper.cc

Issue 196133017: Experimental parser: merge r19949 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 9 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/atomicops_internals_x86_msvc.h ('k') | src/builtins.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 ADD_READONLY_PROTOTYPE, 293 ADD_READONLY_PROTOTYPE,
294 ADD_WRITEABLE_PROTOTYPE 294 ADD_WRITEABLE_PROTOTYPE
295 }; 295 };
296 296
297 Handle<Map> CreateFunctionMap(PrototypePropertyMode prototype_mode); 297 Handle<Map> CreateFunctionMap(PrototypePropertyMode prototype_mode);
298 298
299 void SetFunctionInstanceDescriptor(Handle<Map> map, 299 void SetFunctionInstanceDescriptor(Handle<Map> map,
300 PrototypePropertyMode prototypeMode); 300 PrototypePropertyMode prototypeMode);
301 void MakeFunctionInstancePrototypeWritable(); 301 void MakeFunctionInstancePrototypeWritable();
302 302
303 Handle<Map> CreateStrictModeFunctionMap( 303 Handle<Map> CreateStrictFunctionMap(
304 PrototypePropertyMode prototype_mode, 304 PrototypePropertyMode prototype_mode,
305 Handle<JSFunction> empty_function); 305 Handle<JSFunction> empty_function);
306 306
307 void SetStrictFunctionInstanceDescriptor(Handle<Map> map, 307 void SetStrictFunctionInstanceDescriptor(Handle<Map> map,
308 PrototypePropertyMode propertyMode); 308 PrototypePropertyMode propertyMode);
309 309
310 static bool CompileBuiltin(Isolate* isolate, int index); 310 static bool CompileBuiltin(Isolate* isolate, int index);
311 static bool CompileExperimentalBuiltin(Isolate* isolate, int index); 311 static bool CompileExperimentalBuiltin(Isolate* isolate, int index);
312 static bool CompileNative(Isolate* isolate, 312 static bool CompileNative(Isolate* isolate,
313 Vector<const char> name, 313 Vector<const char> name,
314 Handle<String> source); 314 Handle<String> source);
315 static bool CompileScriptCached(Isolate* isolate, 315 static bool CompileScriptCached(Isolate* isolate,
316 Vector<const char> name, 316 Vector<const char> name,
317 Handle<String> source, 317 Handle<String> source,
318 SourceCodeCache* cache, 318 SourceCodeCache* cache,
319 v8::Extension* extension, 319 v8::Extension* extension,
320 Handle<Context> top_context, 320 Handle<Context> top_context,
321 bool use_runtime_context); 321 bool use_runtime_context);
322 322
323 Isolate* isolate_; 323 Isolate* isolate_;
324 Handle<Context> result_; 324 Handle<Context> result_;
325 Handle<Context> native_context_; 325 Handle<Context> native_context_;
326 326
327 // Function maps. Function maps are created initially with a read only 327 // Function maps. Function maps are created initially with a read only
328 // prototype for the processing of JS builtins. Later the function maps are 328 // prototype for the processing of JS builtins. Later the function maps are
329 // replaced in order to make prototype writable. These are the final, writable 329 // replaced in order to make prototype writable. These are the final, writable
330 // prototype, maps. 330 // prototype, maps.
331 Handle<Map> function_map_writable_prototype_; 331 Handle<Map> sloppy_function_map_writable_prototype_;
332 Handle<Map> strict_mode_function_map_writable_prototype_; 332 Handle<Map> strict_function_map_writable_prototype_;
333 Handle<JSFunction> throw_type_error_function; 333 Handle<JSFunction> throw_type_error_function;
334 334
335 BootstrapperActive active_; 335 BootstrapperActive active_;
336 friend class Bootstrapper; 336 friend class Bootstrapper;
337 }; 337 };
338 338
339 339
340 void Bootstrapper::Iterate(ObjectVisitor* v) { 340 void Bootstrapper::Iterate(ObjectVisitor* v) {
341 extensions_cache_.Iterate(v); 341 extensions_cache_.Iterate(v);
342 v->Synchronize(VisitorSynchronization::kExtensions); 342 v->Synchronize(VisitorSynchronization::kExtensions);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 467
468 468
469 Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) { 469 Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) {
470 // Allocate the map for function instances. Maps are allocated first and their 470 // Allocate the map for function instances. Maps are allocated first and their
471 // prototypes patched later, once empty function is created. 471 // prototypes patched later, once empty function is created.
472 472
473 // Functions with this map will not have a 'prototype' property, and 473 // Functions with this map will not have a 'prototype' property, and
474 // can not be used as constructors. 474 // can not be used as constructors.
475 Handle<Map> function_without_prototype_map = 475 Handle<Map> function_without_prototype_map =
476 CreateFunctionMap(DONT_ADD_PROTOTYPE); 476 CreateFunctionMap(DONT_ADD_PROTOTYPE);
477 native_context()->set_function_without_prototype_map( 477 native_context()->set_sloppy_function_without_prototype_map(
478 *function_without_prototype_map); 478 *function_without_prototype_map);
479 479
480 // Allocate the function map. This map is temporary, used only for processing 480 // Allocate the function map. This map is temporary, used only for processing
481 // of builtins. 481 // of builtins.
482 // Later the map is replaced with writable prototype map, allocated below. 482 // Later the map is replaced with writable prototype map, allocated below.
483 Handle<Map> function_map = CreateFunctionMap(ADD_READONLY_PROTOTYPE); 483 Handle<Map> function_map = CreateFunctionMap(ADD_READONLY_PROTOTYPE);
484 native_context()->set_function_map(*function_map); 484 native_context()->set_sloppy_function_map(*function_map);
485 485
486 // The final map for functions. Writeable prototype. 486 // The final map for functions. Writeable prototype.
487 // This map is installed in MakeFunctionInstancePrototypeWritable. 487 // This map is installed in MakeFunctionInstancePrototypeWritable.
488 function_map_writable_prototype_ = CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE); 488 sloppy_function_map_writable_prototype_ =
489 CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE);
489 490
490 Factory* factory = isolate->factory(); 491 Factory* factory = isolate->factory();
491 492
492 Handle<String> object_name = factory->Object_string(); 493 Handle<String> object_name = factory->Object_string();
493 494
494 { // --- O b j e c t --- 495 { // --- O b j e c t ---
495 Handle<JSFunction> object_fun = 496 Handle<JSFunction> object_fun =
496 factory->NewFunction(object_name, factory->null_value()); 497 factory->NewFunction(object_name, factory->null_value());
497 Handle<Map> object_function_map = 498 Handle<Map> object_function_map =
498 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); 499 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
(...skipping 13 matching lines...) Expand all
512 // assertions during startup. 513 // assertions during startup.
513 native_context()->set_initial_array_prototype(*prototype); 514 native_context()->set_initial_array_prototype(*prototype);
514 Accessors::FunctionSetPrototype(object_fun, prototype); 515 Accessors::FunctionSetPrototype(object_fun, prototype);
515 } 516 }
516 517
517 // Allocate the empty function as the prototype for function ECMAScript 518 // Allocate the empty function as the prototype for function ECMAScript
518 // 262 15.3.4. 519 // 262 15.3.4.
519 Handle<String> empty_string = 520 Handle<String> empty_string =
520 factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("Empty")); 521 factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("Empty"));
521 Handle<JSFunction> empty_function = 522 Handle<JSFunction> empty_function =
522 factory->NewFunctionWithoutPrototype(empty_string, CLASSIC_MODE); 523 factory->NewFunctionWithoutPrototype(empty_string, SLOPPY);
523 524
524 // --- E m p t y --- 525 // --- E m p t y ---
525 Handle<Code> code = 526 Handle<Code> code =
526 Handle<Code>(isolate->builtins()->builtin( 527 Handle<Code>(isolate->builtins()->builtin(
527 Builtins::kEmptyFunction)); 528 Builtins::kEmptyFunction));
528 empty_function->set_code(*code); 529 empty_function->set_code(*code);
529 empty_function->shared()->set_code(*code); 530 empty_function->shared()->set_code(*code);
530 Handle<String> source = 531 Handle<String> source =
531 factory->NewStringFromOneByte(STATIC_ASCII_VECTOR("() {}")); 532 factory->NewStringFromOneByte(STATIC_ASCII_VECTOR("() {}"));
532 Handle<Script> script = factory->NewScript(source); 533 Handle<Script> script = factory->NewScript(source);
533 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); 534 script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
534 empty_function->shared()->set_script(*script); 535 empty_function->shared()->set_script(*script);
535 empty_function->shared()->set_start_position(0); 536 empty_function->shared()->set_start_position(0);
536 empty_function->shared()->set_end_position(source->length()); 537 empty_function->shared()->set_end_position(source->length());
537 empty_function->shared()->DontAdaptArguments(); 538 empty_function->shared()->DontAdaptArguments();
538 539
539 // Set prototypes for the function maps. 540 // Set prototypes for the function maps.
540 native_context()->function_map()->set_prototype(*empty_function); 541 native_context()->sloppy_function_map()->set_prototype(*empty_function);
541 native_context()->function_without_prototype_map()-> 542 native_context()->sloppy_function_without_prototype_map()->
542 set_prototype(*empty_function); 543 set_prototype(*empty_function);
543 function_map_writable_prototype_->set_prototype(*empty_function); 544 sloppy_function_map_writable_prototype_->set_prototype(*empty_function);
544 545
545 // Allocate the function map first and then patch the prototype later 546 // Allocate the function map first and then patch the prototype later
546 Handle<Map> empty_function_map = CreateFunctionMap(DONT_ADD_PROTOTYPE); 547 Handle<Map> empty_function_map = CreateFunctionMap(DONT_ADD_PROTOTYPE);
547 empty_function_map->set_prototype( 548 empty_function_map->set_prototype(
548 native_context()->object_function()->prototype()); 549 native_context()->object_function()->prototype());
549 empty_function->set_map(*empty_function_map); 550 empty_function->set_map(*empty_function_map);
550 return empty_function; 551 return empty_function;
551 } 552 }
552 553
553 554
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 } 598 }
598 } 599 }
599 600
600 601
601 // ECMAScript 5th Edition, 13.2.3 602 // ECMAScript 5th Edition, 13.2.3
602 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() { 603 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() {
603 if (throw_type_error_function.is_null()) { 604 if (throw_type_error_function.is_null()) {
604 Handle<String> name = factory()->InternalizeOneByteString( 605 Handle<String> name = factory()->InternalizeOneByteString(
605 STATIC_ASCII_VECTOR("ThrowTypeError")); 606 STATIC_ASCII_VECTOR("ThrowTypeError"));
606 throw_type_error_function = 607 throw_type_error_function =
607 factory()->NewFunctionWithoutPrototype(name, CLASSIC_MODE); 608 factory()->NewFunctionWithoutPrototype(name, SLOPPY);
608 Handle<Code> code(isolate()->builtins()->builtin( 609 Handle<Code> code(isolate()->builtins()->builtin(
609 Builtins::kStrictModePoisonPill)); 610 Builtins::kStrictModePoisonPill));
610 throw_type_error_function->set_map( 611 throw_type_error_function->set_map(native_context()->sloppy_function_map());
611 native_context()->function_map());
612 throw_type_error_function->set_code(*code); 612 throw_type_error_function->set_code(*code);
613 throw_type_error_function->shared()->set_code(*code); 613 throw_type_error_function->shared()->set_code(*code);
614 throw_type_error_function->shared()->DontAdaptArguments(); 614 throw_type_error_function->shared()->DontAdaptArguments();
615 615
616 JSObject::PreventExtensions(throw_type_error_function); 616 JSObject::PreventExtensions(throw_type_error_function);
617 } 617 }
618 return throw_type_error_function; 618 return throw_type_error_function;
619 } 619 }
620 620
621 621
622 Handle<Map> Genesis::CreateStrictModeFunctionMap( 622 Handle<Map> Genesis::CreateStrictFunctionMap(
623 PrototypePropertyMode prototype_mode, 623 PrototypePropertyMode prototype_mode,
624 Handle<JSFunction> empty_function) { 624 Handle<JSFunction> empty_function) {
625 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); 625 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize);
626 SetStrictFunctionInstanceDescriptor(map, prototype_mode); 626 SetStrictFunctionInstanceDescriptor(map, prototype_mode);
627 map->set_function_with_prototype(prototype_mode != DONT_ADD_PROTOTYPE); 627 map->set_function_with_prototype(prototype_mode != DONT_ADD_PROTOTYPE);
628 map->set_prototype(*empty_function); 628 map->set_prototype(*empty_function);
629 return map; 629 return map;
630 } 630 }
631 631
632 632
633 void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) { 633 void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) {
634 // Allocate map for the prototype-less strict mode instances. 634 // Allocate map for the prototype-less strict mode instances.
635 Handle<Map> strict_mode_function_without_prototype_map = 635 Handle<Map> strict_function_without_prototype_map =
636 CreateStrictModeFunctionMap(DONT_ADD_PROTOTYPE, empty); 636 CreateStrictFunctionMap(DONT_ADD_PROTOTYPE, empty);
637 native_context()->set_strict_mode_function_without_prototype_map( 637 native_context()->set_strict_function_without_prototype_map(
638 *strict_mode_function_without_prototype_map); 638 *strict_function_without_prototype_map);
639 639
640 // Allocate map for the strict mode functions. This map is temporary, used 640 // Allocate map for the strict mode functions. This map is temporary, used
641 // only for processing of builtins. 641 // only for processing of builtins.
642 // Later the map is replaced with writable prototype map, allocated below. 642 // Later the map is replaced with writable prototype map, allocated below.
643 Handle<Map> strict_mode_function_map = 643 Handle<Map> strict_function_map =
644 CreateStrictModeFunctionMap(ADD_READONLY_PROTOTYPE, empty); 644 CreateStrictFunctionMap(ADD_READONLY_PROTOTYPE, empty);
645 native_context()->set_strict_mode_function_map( 645 native_context()->set_strict_function_map(*strict_function_map);
646 *strict_mode_function_map);
647 646
648 // The final map for the strict mode functions. Writeable prototype. 647 // The final map for the strict mode functions. Writeable prototype.
649 // This map is installed in MakeFunctionInstancePrototypeWritable. 648 // This map is installed in MakeFunctionInstancePrototypeWritable.
650 strict_mode_function_map_writable_prototype_ = 649 strict_function_map_writable_prototype_ =
651 CreateStrictModeFunctionMap(ADD_WRITEABLE_PROTOTYPE, empty); 650 CreateStrictFunctionMap(ADD_WRITEABLE_PROTOTYPE, empty);
652 651
653 // Complete the callbacks. 652 // Complete the callbacks.
654 PoisonArgumentsAndCaller(strict_mode_function_without_prototype_map); 653 PoisonArgumentsAndCaller(strict_function_without_prototype_map);
655 PoisonArgumentsAndCaller(strict_mode_function_map); 654 PoisonArgumentsAndCaller(strict_function_map);
656 PoisonArgumentsAndCaller(strict_mode_function_map_writable_prototype_); 655 PoisonArgumentsAndCaller(strict_function_map_writable_prototype_);
657 } 656 }
658 657
659 658
660 static void SetAccessors(Handle<Map> map, 659 static void SetAccessors(Handle<Map> map,
661 Handle<String> name, 660 Handle<String> name,
662 Handle<JSFunction> func) { 661 Handle<JSFunction> func) {
663 DescriptorArray* descs = map->instance_descriptors(); 662 DescriptorArray* descs = map->instance_descriptors();
664 int number = descs->SearchWithCache(*name, *map); 663 int number = descs->SearchWithCache(*name, *map);
665 AccessorPair* accessors = AccessorPair::cast(descs->GetValue(number)); 664 AccessorPair* accessors = AccessorPair::cast(descs->GetValue(number));
666 accessors->set_getter(*func); 665 accessors->set_getter(*func);
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 JS_OBJECT_TYPE, 1129 JS_OBJECT_TYPE,
1131 JSObject::kHeaderSize, 1130 JSObject::kHeaderSize,
1132 prototype, 1131 prototype,
1133 code, 1132 code,
1134 false); 1133 false);
1135 ASSERT(!function->has_initial_map()); 1134 ASSERT(!function->has_initial_map());
1136 function->shared()->set_instance_class_name(*arguments_string); 1135 function->shared()->set_instance_class_name(*arguments_string);
1137 function->shared()->set_expected_nof_properties(2); 1136 function->shared()->set_expected_nof_properties(2);
1138 Handle<JSObject> result = factory->NewJSObject(function); 1137 Handle<JSObject> result = factory->NewJSObject(function);
1139 1138
1140 native_context()->set_arguments_boilerplate(*result); 1139 native_context()->set_sloppy_arguments_boilerplate(*result);
1141 // Note: length must be added as the first property and 1140 // Note: length must be added as the first property and
1142 // callee must be added as the second property. 1141 // callee must be added as the second property.
1143 CHECK_NOT_EMPTY_HANDLE(isolate, 1142 CHECK_NOT_EMPTY_HANDLE(isolate,
1144 JSObject::SetLocalPropertyIgnoreAttributes( 1143 JSObject::SetLocalPropertyIgnoreAttributes(
1145 result, factory->length_string(), 1144 result, factory->length_string(),
1146 factory->undefined_value(), DONT_ENUM, 1145 factory->undefined_value(), DONT_ENUM,
1147 Object::FORCE_TAGGED, FORCE_FIELD)); 1146 Object::FORCE_TAGGED, FORCE_FIELD));
1148 CHECK_NOT_EMPTY_HANDLE(isolate, 1147 CHECK_NOT_EMPTY_HANDLE(isolate,
1149 JSObject::SetLocalPropertyIgnoreAttributes( 1148 JSObject::SetLocalPropertyIgnoreAttributes(
1150 result, factory->callee_string(), 1149 result, factory->callee_string(),
(...skipping 15 matching lines...) Expand all
1166 1165
1167 // Check the state of the object. 1166 // Check the state of the object.
1168 ASSERT(result->HasFastProperties()); 1167 ASSERT(result->HasFastProperties());
1169 ASSERT(result->HasFastObjectElements()); 1168 ASSERT(result->HasFastObjectElements());
1170 #endif 1169 #endif
1171 } 1170 }
1172 1171
1173 { // --- aliased_arguments_boilerplate_ 1172 { // --- aliased_arguments_boilerplate_
1174 // Set up a well-formed parameter map to make assertions happy. 1173 // Set up a well-formed parameter map to make assertions happy.
1175 Handle<FixedArray> elements = factory->NewFixedArray(2); 1174 Handle<FixedArray> elements = factory->NewFixedArray(2);
1176 elements->set_map(heap->non_strict_arguments_elements_map()); 1175 elements->set_map(heap->sloppy_arguments_elements_map());
1177 Handle<FixedArray> array; 1176 Handle<FixedArray> array;
1178 array = factory->NewFixedArray(0); 1177 array = factory->NewFixedArray(0);
1179 elements->set(0, *array); 1178 elements->set(0, *array);
1180 array = factory->NewFixedArray(0); 1179 array = factory->NewFixedArray(0);
1181 elements->set(1, *array); 1180 elements->set(1, *array);
1182 1181
1183 Handle<Map> old_map(native_context()->arguments_boilerplate()->map()); 1182 Handle<Map> old_map(
1183 native_context()->sloppy_arguments_boilerplate()->map());
1184 Handle<Map> new_map = factory->CopyMap(old_map); 1184 Handle<Map> new_map = factory->CopyMap(old_map);
1185 new_map->set_pre_allocated_property_fields(2); 1185 new_map->set_pre_allocated_property_fields(2);
1186 Handle<JSObject> result = factory->NewJSObjectFromMap(new_map); 1186 Handle<JSObject> result = factory->NewJSObjectFromMap(new_map);
1187 // Set elements kind after allocating the object because 1187 // Set elements kind after allocating the object because
1188 // NewJSObjectFromMap assumes a fast elements map. 1188 // NewJSObjectFromMap assumes a fast elements map.
1189 new_map->set_elements_kind(NON_STRICT_ARGUMENTS_ELEMENTS); 1189 new_map->set_elements_kind(SLOPPY_ARGUMENTS_ELEMENTS);
1190 result->set_elements(*elements); 1190 result->set_elements(*elements);
1191 ASSERT(result->HasNonStrictArgumentsElements()); 1191 ASSERT(result->HasSloppyArgumentsElements());
1192 native_context()->set_aliased_arguments_boilerplate(*result); 1192 native_context()->set_aliased_arguments_boilerplate(*result);
1193 } 1193 }
1194 1194
1195 { // --- strict mode arguments boilerplate 1195 { // --- strict mode arguments boilerplate
1196 const PropertyAttributes attributes = 1196 const PropertyAttributes attributes =
1197 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 1197 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
1198 1198
1199 // Create the ThrowTypeError functions. 1199 // Create the ThrowTypeError functions.
1200 Handle<AccessorPair> callee = factory->NewAccessorPair(); 1200 Handle<AccessorPair> callee = factory->NewAccessorPair();
1201 Handle<AccessorPair> caller = factory->NewAccessorPair(); 1201 Handle<AccessorPair> caller = factory->NewAccessorPair();
1202 1202
1203 Handle<JSFunction> throw_function = 1203 Handle<JSFunction> throw_function =
1204 GetThrowTypeErrorFunction(); 1204 GetThrowTypeErrorFunction();
1205 1205
1206 // Install the ThrowTypeError functions. 1206 // Install the ThrowTypeError functions.
1207 callee->set_getter(*throw_function); 1207 callee->set_getter(*throw_function);
1208 callee->set_setter(*throw_function); 1208 callee->set_setter(*throw_function);
1209 caller->set_getter(*throw_function); 1209 caller->set_getter(*throw_function);
1210 caller->set_setter(*throw_function); 1210 caller->set_setter(*throw_function);
1211 1211
1212 // Create the map. Allocate one in-object field for length. 1212 // Create the map. Allocate one in-object field for length.
1213 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, 1213 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE,
1214 Heap::kArgumentsObjectSizeStrict); 1214 Heap::kStrictArgumentsObjectSize);
1215 // Create the descriptor array for the arguments object. 1215 // Create the descriptor array for the arguments object.
1216 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(0, 3); 1216 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(0, 3);
1217 DescriptorArray::WhitenessWitness witness(*descriptors); 1217 DescriptorArray::WhitenessWitness witness(*descriptors);
1218 map->set_instance_descriptors(*descriptors); 1218 map->set_instance_descriptors(*descriptors);
1219 1219
1220 { // length 1220 { // length
1221 FieldDescriptor d( 1221 FieldDescriptor d(
1222 *factory->length_string(), 0, DONT_ENUM, Representation::Tagged()); 1222 *factory->length_string(), 0, DONT_ENUM, Representation::Tagged());
1223 map->AppendDescriptor(&d, witness); 1223 map->AppendDescriptor(&d, witness);
1224 } 1224 }
1225 { // callee 1225 { // callee
1226 CallbacksDescriptor d(*factory->callee_string(), 1226 CallbacksDescriptor d(*factory->callee_string(),
1227 *callee, 1227 *callee,
1228 attributes); 1228 attributes);
1229 map->AppendDescriptor(&d, witness); 1229 map->AppendDescriptor(&d, witness);
1230 } 1230 }
1231 { // caller 1231 { // caller
1232 CallbacksDescriptor d(*factory->caller_string(), 1232 CallbacksDescriptor d(*factory->caller_string(),
1233 *caller, 1233 *caller,
1234 attributes); 1234 attributes);
1235 map->AppendDescriptor(&d, witness); 1235 map->AppendDescriptor(&d, witness);
1236 } 1236 }
1237 1237
1238 map->set_function_with_prototype(true); 1238 map->set_function_with_prototype(true);
1239 map->set_prototype(native_context()->object_function()->prototype()); 1239 map->set_prototype(native_context()->object_function()->prototype());
1240 map->set_pre_allocated_property_fields(1); 1240 map->set_pre_allocated_property_fields(1);
1241 map->set_inobject_properties(1); 1241 map->set_inobject_properties(1);
1242 1242
1243 // Copy constructor from the non-strict arguments boilerplate. 1243 // Copy constructor from the sloppy arguments boilerplate.
1244 map->set_constructor( 1244 map->set_constructor(
1245 native_context()->arguments_boilerplate()->map()->constructor()); 1245 native_context()->sloppy_arguments_boilerplate()->map()->constructor());
1246 1246
1247 // Allocate the arguments boilerplate object. 1247 // Allocate the arguments boilerplate object.
1248 Handle<JSObject> result = factory->NewJSObjectFromMap(map); 1248 Handle<JSObject> result = factory->NewJSObjectFromMap(map);
1249 native_context()->set_strict_mode_arguments_boilerplate(*result); 1249 native_context()->set_strict_arguments_boilerplate(*result);
1250 1250
1251 // Add length property only for strict mode boilerplate. 1251 // Add length property only for strict mode boilerplate.
1252 CHECK_NOT_EMPTY_HANDLE(isolate, 1252 CHECK_NOT_EMPTY_HANDLE(isolate,
1253 JSObject::SetLocalPropertyIgnoreAttributes( 1253 JSObject::SetLocalPropertyIgnoreAttributes(
1254 result, factory->length_string(), 1254 result, factory->length_string(),
1255 factory->undefined_value(), DONT_ENUM)); 1255 factory->undefined_value(), DONT_ENUM));
1256 1256
1257 #ifdef DEBUG 1257 #ifdef DEBUG
1258 LookupResult lookup(isolate); 1258 LookupResult lookup(isolate);
1259 result->LocalLookup(heap->length_string(), &lookup); 1259 result->LocalLookup(heap->length_string(), &lookup);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 JS_FUNCTION_TYPE, JSFunction::kHeaderSize, 1382 JS_FUNCTION_TYPE, JSFunction::kHeaderSize,
1383 generator_object_prototype, Builtins::kIllegal, 1383 generator_object_prototype, Builtins::kIllegal,
1384 false, false); 1384 false, false);
1385 InstallFunction(builtins, "GeneratorFunction", 1385 InstallFunction(builtins, "GeneratorFunction",
1386 JS_FUNCTION_TYPE, JSFunction::kSize, 1386 JS_FUNCTION_TYPE, JSFunction::kSize,
1387 generator_function_prototype, Builtins::kIllegal, 1387 generator_function_prototype, Builtins::kIllegal,
1388 false, false); 1388 false, false);
1389 1389
1390 // Create maps for generator functions and their prototypes. Store those 1390 // Create maps for generator functions and their prototypes. Store those
1391 // maps in the native context. 1391 // maps in the native context.
1392 Handle<Map> function_map(native_context()->function_map()); 1392 Handle<Map> function_map(native_context()->sloppy_function_map());
1393 Handle<Map> generator_function_map = factory()->CopyMap(function_map); 1393 Handle<Map> generator_function_map = factory()->CopyMap(function_map);
1394 generator_function_map->set_prototype(*generator_function_prototype); 1394 generator_function_map->set_prototype(*generator_function_prototype);
1395 native_context()->set_generator_function_map(*generator_function_map); 1395 native_context()->set_sloppy_generator_function_map(
1396 *generator_function_map);
1396 1397
1397 Handle<Map> strict_mode_function_map( 1398 Handle<Map> strict_mode_function_map(
1398 native_context()->strict_mode_function_map()); 1399 native_context()->strict_function_map());
1399 Handle<Map> strict_mode_generator_function_map = factory()->CopyMap( 1400 Handle<Map> strict_mode_generator_function_map = factory()->CopyMap(
1400 strict_mode_function_map); 1401 strict_mode_function_map);
1401 strict_mode_generator_function_map->set_prototype( 1402 strict_mode_generator_function_map->set_prototype(
1402 *generator_function_prototype); 1403 *generator_function_prototype);
1403 native_context()->set_strict_mode_generator_function_map( 1404 native_context()->set_strict_generator_function_map(
1404 *strict_mode_generator_function_map); 1405 *strict_mode_generator_function_map);
1405 1406
1406 Handle<Map> object_map(native_context()->object_function()->initial_map()); 1407 Handle<Map> object_map(native_context()->object_function()->initial_map());
1407 Handle<Map> generator_object_prototype_map = factory()->CopyMap( 1408 Handle<Map> generator_object_prototype_map = factory()->CopyMap(
1408 object_map, 0); 1409 object_map, 0);
1409 generator_object_prototype_map->set_prototype( 1410 generator_object_prototype_map->set_prototype(
1410 *generator_object_prototype); 1411 *generator_object_prototype);
1411 native_context()->set_generator_object_prototype_map( 1412 native_context()->set_generator_object_prototype_map(
1412 *generator_object_prototype_map); 1413 *generator_object_prototype_map);
1413 1414
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1513 Handle<String> script_name = factory->NewStringFromUtf8(name); 1514 Handle<String> script_name = factory->NewStringFromUtf8(name);
1514 function_info = Compiler::CompileScript( 1515 function_info = Compiler::CompileScript(
1515 source, 1516 source,
1516 script_name, 1517 script_name,
1517 0, 1518 0,
1518 0, 1519 0,
1519 false, 1520 false,
1520 top_context, 1521 top_context,
1521 extension, 1522 extension,
1522 NULL, 1523 NULL,
1523 Handle<String>::null(),
1524 use_runtime_context ? NATIVES_CODE : NOT_NATIVES_CODE); 1524 use_runtime_context ? NATIVES_CODE : NOT_NATIVES_CODE);
1525 if (function_info.is_null()) return false; 1525 if (function_info.is_null()) return false;
1526 if (cache != NULL) cache->Add(name, function_info); 1526 if (cache != NULL) cache->Add(name, function_info);
1527 } 1527 }
1528 1528
1529 // Set up the function context. Conceptually, we should clone the 1529 // Set up the function context. Conceptually, we should clone the
1530 // function before overwriting the context but since we're in a 1530 // function before overwriting the context but since we're in a
1531 // single-threaded environment it is not strictly necessary. 1531 // single-threaded environment it is not strictly necessary.
1532 ASSERT(top_context->IsNativeContext()); 1532 ASSERT(top_context->IsNativeContext());
1533 Handle<Context> context = 1533 Handle<Context> context =
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 INSTALL_NATIVE(JSFunction, "ToUint32", to_uint32_fun); 1571 INSTALL_NATIVE(JSFunction, "ToUint32", to_uint32_fun);
1572 INSTALL_NATIVE(JSFunction, "ToInt32", to_int32_fun); 1572 INSTALL_NATIVE(JSFunction, "ToInt32", to_int32_fun);
1573 INSTALL_NATIVE(JSFunction, "GlobalEval", global_eval_fun); 1573 INSTALL_NATIVE(JSFunction, "GlobalEval", global_eval_fun);
1574 INSTALL_NATIVE(JSFunction, "Instantiate", instantiate_fun); 1574 INSTALL_NATIVE(JSFunction, "Instantiate", instantiate_fun);
1575 INSTALL_NATIVE(JSFunction, "ConfigureTemplateInstance", 1575 INSTALL_NATIVE(JSFunction, "ConfigureTemplateInstance",
1576 configure_instance_fun); 1576 configure_instance_fun);
1577 INSTALL_NATIVE(JSFunction, "GetStackTraceLine", get_stack_trace_line_fun); 1577 INSTALL_NATIVE(JSFunction, "GetStackTraceLine", get_stack_trace_line_fun);
1578 INSTALL_NATIVE(JSObject, "functionCache", function_cache); 1578 INSTALL_NATIVE(JSObject, "functionCache", function_cache);
1579 INSTALL_NATIVE(JSFunction, "ToCompletePropertyDescriptor", 1579 INSTALL_NATIVE(JSFunction, "ToCompletePropertyDescriptor",
1580 to_complete_property_descriptor); 1580 to_complete_property_descriptor);
1581 INSTALL_NATIVE(JSFunction, "NotifyChange", observers_notify_change);
1582 INSTALL_NATIVE(JSFunction, "EnqueueSpliceRecord", observers_enqueue_splice);
1583 INSTALL_NATIVE(JSFunction, "BeginPerformSplice",
1584 observers_begin_perform_splice);
1585 INSTALL_NATIVE(JSFunction, "EndPerformSplice",
1586 observers_end_perform_splice);
1581 } 1587 }
1582 1588
1583 1589
1584 void Genesis::InstallExperimentalNativeFunctions() { 1590 void Genesis::InstallExperimentalNativeFunctions() {
1585 INSTALL_NATIVE(JSFunction, "RunMicrotasks", run_microtasks); 1591 INSTALL_NATIVE(JSFunction, "RunMicrotasks", run_microtasks);
1586 INSTALL_NATIVE(JSFunction, "EnqueueExternalMicrotask", 1592 INSTALL_NATIVE(JSFunction, "EnqueueExternalMicrotask",
1587 enqueue_external_microtask); 1593 enqueue_external_microtask);
1588 1594
1595 if (FLAG_harmony_promises) {
1596 INSTALL_NATIVE(JSFunction, "IsPromise", is_promise);
1597 INSTALL_NATIVE(JSFunction, "PromiseCreate", promise_create);
1598 INSTALL_NATIVE(JSFunction, "PromiseResolve", promise_resolve);
1599 INSTALL_NATIVE(JSFunction, "PromiseReject", promise_reject);
1600 INSTALL_NATIVE(JSFunction, "PromiseChain", promise_chain);
1601 INSTALL_NATIVE(JSFunction, "PromiseCatch", promise_catch);
1602 }
1603
1589 if (FLAG_harmony_proxies) { 1604 if (FLAG_harmony_proxies) {
1590 INSTALL_NATIVE(JSFunction, "DerivedHasTrap", derived_has_trap); 1605 INSTALL_NATIVE(JSFunction, "DerivedHasTrap", derived_has_trap);
1591 INSTALL_NATIVE(JSFunction, "DerivedGetTrap", derived_get_trap); 1606 INSTALL_NATIVE(JSFunction, "DerivedGetTrap", derived_get_trap);
1592 INSTALL_NATIVE(JSFunction, "DerivedSetTrap", derived_set_trap); 1607 INSTALL_NATIVE(JSFunction, "DerivedSetTrap", derived_set_trap);
1593 INSTALL_NATIVE(JSFunction, "ProxyEnumerate", proxy_enumerate); 1608 INSTALL_NATIVE(JSFunction, "ProxyEnumerate", proxy_enumerate);
1594 } 1609 }
1595 if (FLAG_harmony_observation) {
1596 INSTALL_NATIVE(JSFunction, "NotifyChange", observers_notify_change);
1597 INSTALL_NATIVE(JSFunction, "EnqueueSpliceRecord", observers_enqueue_splice);
1598 INSTALL_NATIVE(JSFunction, "BeginPerformSplice",
1599 observers_begin_perform_splice);
1600 INSTALL_NATIVE(JSFunction, "EndPerformSplice",
1601 observers_end_perform_splice);
1602 }
1603 } 1610 }
1604 1611
1605 #undef INSTALL_NATIVE 1612 #undef INSTALL_NATIVE
1606 1613
1607 1614
1608 Handle<JSFunction> Genesis::InstallInternalArray( 1615 Handle<JSFunction> Genesis::InstallInternalArray(
1609 Handle<JSBuiltinsObject> builtins, 1616 Handle<JSBuiltinsObject> builtins,
1610 const char* name, 1617 const char* name,
1611 ElementsKind elements_kind) { 1618 ElementsKind elements_kind) {
1612 // --- I n t e r n a l A r r a y --- 1619 // --- I n t e r n a l A r r a y ---
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 Handle<String> line_offset_string( 1755 Handle<String> line_offset_string(
1749 factory()->InternalizeOneByteString( 1756 factory()->InternalizeOneByteString(
1750 STATIC_ASCII_VECTOR("line_offset"))); 1757 STATIC_ASCII_VECTOR("line_offset")));
1751 Handle<Foreign> script_line_offset( 1758 Handle<Foreign> script_line_offset(
1752 factory()->NewForeign(&Accessors::ScriptLineOffset)); 1759 factory()->NewForeign(&Accessors::ScriptLineOffset));
1753 Handle<String> column_offset_string( 1760 Handle<String> column_offset_string(
1754 factory()->InternalizeOneByteString( 1761 factory()->InternalizeOneByteString(
1755 STATIC_ASCII_VECTOR("column_offset"))); 1762 STATIC_ASCII_VECTOR("column_offset")));
1756 Handle<Foreign> script_column_offset( 1763 Handle<Foreign> script_column_offset(
1757 factory()->NewForeign(&Accessors::ScriptColumnOffset)); 1764 factory()->NewForeign(&Accessors::ScriptColumnOffset));
1758 Handle<String> data_string(factory()->InternalizeOneByteString(
1759 STATIC_ASCII_VECTOR("data")));
1760 Handle<Foreign> script_data(factory()->NewForeign(&Accessors::ScriptData));
1761 Handle<String> type_string(factory()->InternalizeOneByteString( 1765 Handle<String> type_string(factory()->InternalizeOneByteString(
1762 STATIC_ASCII_VECTOR("type"))); 1766 STATIC_ASCII_VECTOR("type")));
1763 Handle<Foreign> script_type(factory()->NewForeign(&Accessors::ScriptType)); 1767 Handle<Foreign> script_type(factory()->NewForeign(&Accessors::ScriptType));
1764 Handle<String> compilation_type_string( 1768 Handle<String> compilation_type_string(
1765 factory()->InternalizeOneByteString( 1769 factory()->InternalizeOneByteString(
1766 STATIC_ASCII_VECTOR("compilation_type"))); 1770 STATIC_ASCII_VECTOR("compilation_type")));
1767 Handle<Foreign> script_compilation_type( 1771 Handle<Foreign> script_compilation_type(
1768 factory()->NewForeign(&Accessors::ScriptCompilationType)); 1772 factory()->NewForeign(&Accessors::ScriptCompilationType));
1769 Handle<String> line_ends_string(factory()->InternalizeOneByteString( 1773 Handle<String> line_ends_string(factory()->InternalizeOneByteString(
1770 STATIC_ASCII_VECTOR("line_ends"))); 1774 STATIC_ASCII_VECTOR("line_ends")));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1815 script_map->AppendDescriptor(&d, witness); 1819 script_map->AppendDescriptor(&d, witness);
1816 } 1820 }
1817 1821
1818 { 1822 {
1819 CallbacksDescriptor d( 1823 CallbacksDescriptor d(
1820 *column_offset_string, *script_column_offset, attribs); 1824 *column_offset_string, *script_column_offset, attribs);
1821 script_map->AppendDescriptor(&d, witness); 1825 script_map->AppendDescriptor(&d, witness);
1822 } 1826 }
1823 1827
1824 { 1828 {
1825 CallbacksDescriptor d(*data_string, *script_data, attribs);
1826 script_map->AppendDescriptor(&d, witness);
1827 }
1828
1829 {
1830 CallbacksDescriptor d(*type_string, *script_type, attribs); 1829 CallbacksDescriptor d(*type_string, *script_type, attribs);
1831 script_map->AppendDescriptor(&d, witness); 1830 script_map->AppendDescriptor(&d, witness);
1832 } 1831 }
1833 1832
1834 { 1833 {
1835 CallbacksDescriptor d( 1834 CallbacksDescriptor d(
1836 *compilation_type_string, *script_compilation_type, attribs); 1835 *compilation_type_string, *script_compilation_type, attribs);
1837 script_map->AppendDescriptor(&d, witness); 1836 script_map->AppendDescriptor(&d, witness);
1838 } 1837 }
1839 1838
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
2044 } 2043 }
2045 2044
2046 2045
2047 bool Genesis::InstallExperimentalNatives() { 2046 bool Genesis::InstallExperimentalNatives() {
2048 for (int i = ExperimentalNatives::GetDebuggerCount(); 2047 for (int i = ExperimentalNatives::GetDebuggerCount();
2049 i < ExperimentalNatives::GetBuiltinsCount(); 2048 i < ExperimentalNatives::GetBuiltinsCount();
2050 i++) { 2049 i++) {
2051 INSTALL_EXPERIMENTAL_NATIVE(i, symbols, "symbol.js") 2050 INSTALL_EXPERIMENTAL_NATIVE(i, symbols, "symbol.js")
2052 INSTALL_EXPERIMENTAL_NATIVE(i, proxies, "proxy.js") 2051 INSTALL_EXPERIMENTAL_NATIVE(i, proxies, "proxy.js")
2053 INSTALL_EXPERIMENTAL_NATIVE(i, collections, "collection.js") 2052 INSTALL_EXPERIMENTAL_NATIVE(i, collections, "collection.js")
2054 INSTALL_EXPERIMENTAL_NATIVE(i, observation, "object-observe.js")
2055 INSTALL_EXPERIMENTAL_NATIVE(i, promises, "promise.js") 2053 INSTALL_EXPERIMENTAL_NATIVE(i, promises, "promise.js")
2056 INSTALL_EXPERIMENTAL_NATIVE(i, generators, "generator.js") 2054 INSTALL_EXPERIMENTAL_NATIVE(i, generators, "generator.js")
2057 INSTALL_EXPERIMENTAL_NATIVE(i, iteration, "array-iterator.js") 2055 INSTALL_EXPERIMENTAL_NATIVE(i, iteration, "array-iterator.js")
2058 INSTALL_EXPERIMENTAL_NATIVE(i, strings, "harmony-string.js") 2056 INSTALL_EXPERIMENTAL_NATIVE(i, strings, "harmony-string.js")
2059 INSTALL_EXPERIMENTAL_NATIVE(i, arrays, "harmony-array.js") 2057 INSTALL_EXPERIMENTAL_NATIVE(i, arrays, "harmony-array.js")
2060 INSTALL_EXPERIMENTAL_NATIVE(i, maths, "harmony-math.js") 2058 INSTALL_EXPERIMENTAL_NATIVE(i, maths, "harmony-math.js")
2061 } 2059 }
2062 2060
2063 InstallExperimentalNativeFunctions(); 2061 InstallExperimentalNativeFunctions();
2064 InstallExperimentalBuiltinFunctionIds(); 2062 InstallExperimentalBuiltinFunctionIds();
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
2552 Handle<Map> new_to_map = factory()->CopyMap(old_to_map); 2550 Handle<Map> new_to_map = factory()->CopyMap(old_to_map);
2553 new_to_map->set_prototype(from->map()->prototype()); 2551 new_to_map->set_prototype(from->map()->prototype());
2554 to->set_map(*new_to_map); 2552 to->set_map(*new_to_map);
2555 } 2553 }
2556 2554
2557 2555
2558 void Genesis::MakeFunctionInstancePrototypeWritable() { 2556 void Genesis::MakeFunctionInstancePrototypeWritable() {
2559 // The maps with writable prototype are created in CreateEmptyFunction 2557 // The maps with writable prototype are created in CreateEmptyFunction
2560 // and CreateStrictModeFunctionMaps respectively. Initially the maps are 2558 // and CreateStrictModeFunctionMaps respectively. Initially the maps are
2561 // created with read-only prototype for JS builtins processing. 2559 // created with read-only prototype for JS builtins processing.
2562 ASSERT(!function_map_writable_prototype_.is_null()); 2560 ASSERT(!sloppy_function_map_writable_prototype_.is_null());
2563 ASSERT(!strict_mode_function_map_writable_prototype_.is_null()); 2561 ASSERT(!strict_function_map_writable_prototype_.is_null());
2564 2562
2565 // Replace function instance maps to make prototype writable. 2563 // Replace function instance maps to make prototype writable.
2566 native_context()->set_function_map(*function_map_writable_prototype_); 2564 native_context()->set_sloppy_function_map(
2567 native_context()->set_strict_mode_function_map( 2565 *sloppy_function_map_writable_prototype_);
2568 *strict_mode_function_map_writable_prototype_); 2566 native_context()->set_strict_function_map(
2567 *strict_function_map_writable_prototype_);
2569 } 2568 }
2570 2569
2571 2570
2572 class NoTrackDoubleFieldsForSerializerScope { 2571 class NoTrackDoubleFieldsForSerializerScope {
2573 public: 2572 public:
2574 NoTrackDoubleFieldsForSerializerScope() : flag_(FLAG_track_double_fields) { 2573 NoTrackDoubleFieldsForSerializerScope() : flag_(FLAG_track_double_fields) {
2575 if (Serializer::enabled()) { 2574 if (Serializer::enabled()) {
2576 // Disable tracking double fields because heap numbers treated as 2575 // Disable tracking double fields because heap numbers treated as
2577 // immutable by the serializer. 2576 // immutable by the serializer.
2578 FLAG_track_double_fields = false; 2577 FLAG_track_double_fields = false;
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
2746 return from + sizeof(NestingCounterType); 2745 return from + sizeof(NestingCounterType);
2747 } 2746 }
2748 2747
2749 2748
2750 // Called when the top-level V8 mutex is destroyed. 2749 // Called when the top-level V8 mutex is destroyed.
2751 void Bootstrapper::FreeThreadResources() { 2750 void Bootstrapper::FreeThreadResources() {
2752 ASSERT(!IsActive()); 2751 ASSERT(!IsActive());
2753 } 2752 }
2754 2753
2755 } } // namespace v8::internal 2754 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/atomicops_internals_x86_msvc.h ('k') | src/builtins.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698