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

Side by Side Diff: src/bootstrapper.cc

Issue 12210083: Renamed "symbols" to "internalized strings" throughout the code base, (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed Yang's comments Created 7 years, 10 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/ast.cc ('k') | src/code-stubs.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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 346
347 static Handle<JSFunction> InstallFunction(Handle<JSObject> target, 347 static Handle<JSFunction> InstallFunction(Handle<JSObject> target,
348 const char* name, 348 const char* name,
349 InstanceType type, 349 InstanceType type,
350 int instance_size, 350 int instance_size,
351 Handle<JSObject> prototype, 351 Handle<JSObject> prototype,
352 Builtins::Name call, 352 Builtins::Name call,
353 bool is_ecma_native) { 353 bool is_ecma_native) {
354 Isolate* isolate = target->GetIsolate(); 354 Isolate* isolate = target->GetIsolate();
355 Factory* factory = isolate->factory(); 355 Factory* factory = isolate->factory();
356 Handle<String> symbol = factory->LookupUtf8Symbol(name); 356 Handle<String> internalized_name = factory->InternalizeUtf8String(name);
357 Handle<Code> call_code = Handle<Code>(isolate->builtins()->builtin(call)); 357 Handle<Code> call_code = Handle<Code>(isolate->builtins()->builtin(call));
358 Handle<JSFunction> function = prototype.is_null() ? 358 Handle<JSFunction> function = prototype.is_null() ?
359 factory->NewFunctionWithoutPrototype(symbol, call_code) : 359 factory->NewFunctionWithoutPrototype(internalized_name, call_code) :
360 factory->NewFunctionWithPrototype(symbol, 360 factory->NewFunctionWithPrototype(internalized_name,
361 type, 361 type,
362 instance_size, 362 instance_size,
363 prototype, 363 prototype,
364 call_code, 364 call_code,
365 is_ecma_native); 365 is_ecma_native);
366 PropertyAttributes attributes; 366 PropertyAttributes attributes;
367 if (target->IsJSBuiltinsObject()) { 367 if (target->IsJSBuiltinsObject()) {
368 attributes = 368 attributes =
369 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 369 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
370 } else { 370 } else {
371 attributes = DONT_ENUM; 371 attributes = DONT_ENUM;
372 } 372 }
373 CHECK_NOT_EMPTY_HANDLE(isolate, 373 CHECK_NOT_EMPTY_HANDLE(isolate,
374 JSObject::SetLocalPropertyIgnoreAttributes( 374 JSObject::SetLocalPropertyIgnoreAttributes(
375 target, symbol, function, attributes)); 375 target, internalized_name, function, attributes));
376 if (is_ecma_native) { 376 if (is_ecma_native) {
377 function->shared()->set_instance_class_name(*symbol); 377 function->shared()->set_instance_class_name(*internalized_name);
378 } 378 }
379 function->shared()->set_native(true); 379 function->shared()->set_native(true);
380 return function; 380 return function;
381 } 381 }
382 382
383 383
384 void Genesis::SetFunctionInstanceDescriptor( 384 void Genesis::SetFunctionInstanceDescriptor(
385 Handle<Map> map, PrototypePropertyMode prototypeMode) { 385 Handle<Map> map, PrototypePropertyMode prototypeMode) {
386 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5; 386 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5;
387 Handle<DescriptorArray> descriptors(factory()->NewDescriptorArray(0, size)); 387 Handle<DescriptorArray> descriptors(factory()->NewDescriptorArray(0, size));
388 DescriptorArray::WhitenessWitness witness(*descriptors); 388 DescriptorArray::WhitenessWitness witness(*descriptors);
389 389
390 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength)); 390 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength));
391 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName)); 391 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName));
392 Handle<Foreign> args(factory()->NewForeign(&Accessors::FunctionArguments)); 392 Handle<Foreign> args(factory()->NewForeign(&Accessors::FunctionArguments));
393 Handle<Foreign> caller(factory()->NewForeign(&Accessors::FunctionCaller)); 393 Handle<Foreign> caller(factory()->NewForeign(&Accessors::FunctionCaller));
394 Handle<Foreign> prototype; 394 Handle<Foreign> prototype;
395 if (prototypeMode != DONT_ADD_PROTOTYPE) { 395 if (prototypeMode != DONT_ADD_PROTOTYPE) {
396 prototype = factory()->NewForeign(&Accessors::FunctionPrototype); 396 prototype = factory()->NewForeign(&Accessors::FunctionPrototype);
397 } 397 }
398 PropertyAttributes attribs = static_cast<PropertyAttributes>( 398 PropertyAttributes attribs = static_cast<PropertyAttributes>(
399 DONT_ENUM | DONT_DELETE | READ_ONLY); 399 DONT_ENUM | DONT_DELETE | READ_ONLY);
400 map->set_instance_descriptors(*descriptors); 400 map->set_instance_descriptors(*descriptors);
401 401
402 { // Add length. 402 { // Add length.
403 CallbacksDescriptor d(*factory()->length_symbol(), *length, attribs); 403 CallbacksDescriptor d(*factory()->length_string(), *length, attribs);
404 map->AppendDescriptor(&d, witness); 404 map->AppendDescriptor(&d, witness);
405 } 405 }
406 { // Add name. 406 { // Add name.
407 CallbacksDescriptor d(*factory()->name_symbol(), *name, attribs); 407 CallbacksDescriptor d(*factory()->name_string(), *name, attribs);
408 map->AppendDescriptor(&d, witness); 408 map->AppendDescriptor(&d, witness);
409 } 409 }
410 { // Add arguments. 410 { // Add arguments.
411 CallbacksDescriptor d(*factory()->arguments_symbol(), *args, attribs); 411 CallbacksDescriptor d(*factory()->arguments_string(), *args, attribs);
412 map->AppendDescriptor(&d, witness); 412 map->AppendDescriptor(&d, witness);
413 } 413 }
414 { // Add caller. 414 { // Add caller.
415 CallbacksDescriptor d(*factory()->caller_symbol(), *caller, attribs); 415 CallbacksDescriptor d(*factory()->caller_string(), *caller, attribs);
416 map->AppendDescriptor(&d, witness); 416 map->AppendDescriptor(&d, witness);
417 } 417 }
418 if (prototypeMode != DONT_ADD_PROTOTYPE) { 418 if (prototypeMode != DONT_ADD_PROTOTYPE) {
419 // Add prototype. 419 // Add prototype.
420 if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) { 420 if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) {
421 attribs = static_cast<PropertyAttributes>(attribs & ~READ_ONLY); 421 attribs = static_cast<PropertyAttributes>(attribs & ~READ_ONLY);
422 } 422 }
423 CallbacksDescriptor d(*factory()->prototype_symbol(), *prototype, attribs); 423 CallbacksDescriptor d(*factory()->prototype_string(), *prototype, attribs);
424 map->AppendDescriptor(&d, witness); 424 map->AppendDescriptor(&d, witness);
425 } 425 }
426 } 426 }
427 427
428 428
429 Handle<Map> Genesis::CreateFunctionMap(PrototypePropertyMode prototype_mode) { 429 Handle<Map> Genesis::CreateFunctionMap(PrototypePropertyMode prototype_mode) {
430 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); 430 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize);
431 SetFunctionInstanceDescriptor(map, prototype_mode); 431 SetFunctionInstanceDescriptor(map, prototype_mode);
432 map->set_function_with_prototype(prototype_mode != DONT_ADD_PROTOTYPE); 432 map->set_function_with_prototype(prototype_mode != DONT_ADD_PROTOTYPE);
433 return map; 433 return map;
(...skipping 24 matching lines...) Expand all
458 native_context()->set_function_map(*function_map); 458 native_context()->set_function_map(*function_map);
459 459
460 // The final map for functions. Writeable prototype. 460 // The final map for functions. Writeable prototype.
461 // This map is installed in MakeFunctionInstancePrototypeWritable. 461 // This map is installed in MakeFunctionInstancePrototypeWritable.
462 function_instance_map_writable_prototype_ = 462 function_instance_map_writable_prototype_ =
463 CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE); 463 CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE);
464 464
465 Factory* factory = isolate->factory(); 465 Factory* factory = isolate->factory();
466 Heap* heap = isolate->heap(); 466 Heap* heap = isolate->heap();
467 467
468 Handle<String> object_name = Handle<String>(heap->Object_symbol()); 468 Handle<String> object_name = Handle<String>(heap->Object_string());
469 469
470 { // --- O b j e c t --- 470 { // --- O b j e c t ---
471 Handle<JSFunction> object_fun = 471 Handle<JSFunction> object_fun =
472 factory->NewFunction(object_name, factory->null_value()); 472 factory->NewFunction(object_name, factory->null_value());
473 Handle<Map> object_function_map = 473 Handle<Map> object_function_map =
474 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); 474 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
475 object_fun->set_initial_map(*object_function_map); 475 object_fun->set_initial_map(*object_function_map);
476 object_function_map->set_constructor(*object_fun); 476 object_function_map->set_constructor(*object_fun);
477 477
478 native_context()->set_object_function(*object_fun); 478 native_context()->set_object_function(*object_fun);
479 479
480 // Allocate a new prototype for the object function. 480 // Allocate a new prototype for the object function.
481 Handle<JSObject> prototype = factory->NewJSObject( 481 Handle<JSObject> prototype = factory->NewJSObject(
482 isolate->object_function(), 482 isolate->object_function(),
483 TENURED); 483 TENURED);
484 484
485 native_context()->set_initial_object_prototype(*prototype); 485 native_context()->set_initial_object_prototype(*prototype);
486 SetPrototype(object_fun, prototype); 486 SetPrototype(object_fun, prototype);
487 } 487 }
488 488
489 // Allocate the empty function as the prototype for function ECMAScript 489 // Allocate the empty function as the prototype for function ECMAScript
490 // 262 15.3.4. 490 // 262 15.3.4.
491 Handle<String> symbol = 491 Handle<String> empty_string =
492 factory->LookupOneByteSymbol(STATIC_ASCII_VECTOR("Empty")); 492 factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("Empty"));
493 Handle<JSFunction> empty_function = 493 Handle<JSFunction> empty_function =
494 factory->NewFunctionWithoutPrototype(symbol, CLASSIC_MODE); 494 factory->NewFunctionWithoutPrototype(empty_string, CLASSIC_MODE);
495 495
496 // --- E m p t y --- 496 // --- E m p t y ---
497 Handle<Code> code = 497 Handle<Code> code =
498 Handle<Code>(isolate->builtins()->builtin( 498 Handle<Code>(isolate->builtins()->builtin(
499 Builtins::kEmptyFunction)); 499 Builtins::kEmptyFunction));
500 empty_function->set_code(*code); 500 empty_function->set_code(*code);
501 empty_function->shared()->set_code(*code); 501 empty_function->shared()->set_code(*code);
502 Handle<String> source = 502 Handle<String> source =
503 factory->NewStringFromOneByte(STATIC_ASCII_VECTOR("() {}")); 503 factory->NewStringFromOneByte(STATIC_ASCII_VECTOR("() {}"));
504 Handle<Script> script = factory->NewScript(source); 504 Handle<Script> script = factory->NewScript(source);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 Handle<AccessorPair> caller(factory()->NewAccessorPair()); 536 Handle<AccessorPair> caller(factory()->NewAccessorPair());
537 Handle<Foreign> prototype; 537 Handle<Foreign> prototype;
538 if (prototypeMode != DONT_ADD_PROTOTYPE) { 538 if (prototypeMode != DONT_ADD_PROTOTYPE) {
539 prototype = factory()->NewForeign(&Accessors::FunctionPrototype); 539 prototype = factory()->NewForeign(&Accessors::FunctionPrototype);
540 } 540 }
541 PropertyAttributes attribs = static_cast<PropertyAttributes>( 541 PropertyAttributes attribs = static_cast<PropertyAttributes>(
542 DONT_ENUM | DONT_DELETE); 542 DONT_ENUM | DONT_DELETE);
543 map->set_instance_descriptors(*descriptors); 543 map->set_instance_descriptors(*descriptors);
544 544
545 { // Add length. 545 { // Add length.
546 CallbacksDescriptor d(*factory()->length_symbol(), *length, attribs); 546 CallbacksDescriptor d(*factory()->length_string(), *length, attribs);
547 map->AppendDescriptor(&d, witness); 547 map->AppendDescriptor(&d, witness);
548 } 548 }
549 { // Add name. 549 { // Add name.
550 CallbacksDescriptor d(*factory()->name_symbol(), *name, attribs); 550 CallbacksDescriptor d(*factory()->name_string(), *name, attribs);
551 map->AppendDescriptor(&d, witness); 551 map->AppendDescriptor(&d, witness);
552 } 552 }
553 { // Add arguments. 553 { // Add arguments.
554 CallbacksDescriptor d(*factory()->arguments_symbol(), *arguments, attribs); 554 CallbacksDescriptor d(*factory()->arguments_string(), *arguments, attribs);
555 map->AppendDescriptor(&d, witness); 555 map->AppendDescriptor(&d, witness);
556 } 556 }
557 { // Add caller. 557 { // Add caller.
558 CallbacksDescriptor d(*factory()->caller_symbol(), *caller, attribs); 558 CallbacksDescriptor d(*factory()->caller_string(), *caller, attribs);
559 map->AppendDescriptor(&d, witness); 559 map->AppendDescriptor(&d, witness);
560 } 560 }
561 if (prototypeMode != DONT_ADD_PROTOTYPE) { 561 if (prototypeMode != DONT_ADD_PROTOTYPE) {
562 // Add prototype. 562 // Add prototype.
563 if (prototypeMode != ADD_WRITEABLE_PROTOTYPE) { 563 if (prototypeMode != ADD_WRITEABLE_PROTOTYPE) {
564 attribs = static_cast<PropertyAttributes>(attribs | READ_ONLY); 564 attribs = static_cast<PropertyAttributes>(attribs | READ_ONLY);
565 } 565 }
566 CallbacksDescriptor d(*factory()->prototype_symbol(), *prototype, attribs); 566 CallbacksDescriptor d(*factory()->prototype_string(), *prototype, attribs);
567 map->AppendDescriptor(&d, witness); 567 map->AppendDescriptor(&d, witness);
568 } 568 }
569 } 569 }
570 570
571 571
572 // ECMAScript 5th Edition, 13.2.3 572 // ECMAScript 5th Edition, 13.2.3
573 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() { 573 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() {
574 if (throw_type_error_function.is_null()) { 574 if (throw_type_error_function.is_null()) {
575 Handle<String> name = factory()->LookupOneByteSymbol( 575 Handle<String> name = factory()->InternalizeOneByteString(
576 STATIC_ASCII_VECTOR("ThrowTypeError")); 576 STATIC_ASCII_VECTOR("ThrowTypeError"));
577 throw_type_error_function = 577 throw_type_error_function =
578 factory()->NewFunctionWithoutPrototype(name, CLASSIC_MODE); 578 factory()->NewFunctionWithoutPrototype(name, CLASSIC_MODE);
579 Handle<Code> code(isolate()->builtins()->builtin( 579 Handle<Code> code(isolate()->builtins()->builtin(
580 Builtins::kStrictModePoisonPill)); 580 Builtins::kStrictModePoisonPill));
581 throw_type_error_function->set_map( 581 throw_type_error_function->set_map(
582 native_context()->function_map()); 582 native_context()->function_map());
583 throw_type_error_function->set_code(*code); 583 throw_type_error_function->set_code(*code);
584 throw_type_error_function->shared()->set_code(*code); 584 throw_type_error_function->shared()->set_code(*code);
585 throw_type_error_function->shared()->DontAdaptArguments(); 585 throw_type_error_function->shared()->DontAdaptArguments();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 Handle<JSFunction> func) { 641 Handle<JSFunction> func) {
642 DescriptorArray* descs = map->instance_descriptors(); 642 DescriptorArray* descs = map->instance_descriptors();
643 int number = descs->SearchWithCache(*name, *map); 643 int number = descs->SearchWithCache(*name, *map);
644 AccessorPair* accessors = AccessorPair::cast(descs->GetValue(number)); 644 AccessorPair* accessors = AccessorPair::cast(descs->GetValue(number));
645 accessors->set_getter(*func); 645 accessors->set_getter(*func);
646 accessors->set_setter(*func); 646 accessors->set_setter(*func);
647 } 647 }
648 648
649 649
650 void Genesis::PoisonArgumentsAndCaller(Handle<Map> map) { 650 void Genesis::PoisonArgumentsAndCaller(Handle<Map> map) {
651 SetAccessors(map, factory()->arguments_symbol(), GetThrowTypeErrorFunction()); 651 SetAccessors(map, factory()->arguments_string(), GetThrowTypeErrorFunction());
652 SetAccessors(map, factory()->caller_symbol(), GetThrowTypeErrorFunction()); 652 SetAccessors(map, factory()->caller_string(), GetThrowTypeErrorFunction());
653 } 653 }
654 654
655 655
656 static void AddToWeakNativeContextList(Context* context) { 656 static void AddToWeakNativeContextList(Context* context) {
657 ASSERT(context->IsNativeContext()); 657 ASSERT(context->IsNativeContext());
658 Heap* heap = context->GetIsolate()->heap(); 658 Heap* heap = context->GetIsolate()->heap();
659 #ifdef DEBUG 659 #ifdef DEBUG
660 { // NOLINT 660 { // NOLINT
661 ASSERT(context->get(Context::NEXT_CONTEXT_LINK)->IsUndefined()); 661 ASSERT(context->get(Context::NEXT_CONTEXT_LINK)->IsUndefined());
662 // Check that context is not in the list yet. 662 // Check that context is not in the list yet.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 Handle<FunctionTemplateInfo>( 717 Handle<FunctionTemplateInfo>(
718 FunctionTemplateInfo::cast(data->constructor())); 718 FunctionTemplateInfo::cast(data->constructor()));
719 Handle<Object> proto_template(global_constructor->prototype_template()); 719 Handle<Object> proto_template(global_constructor->prototype_template());
720 if (!proto_template->IsUndefined()) { 720 if (!proto_template->IsUndefined()) {
721 js_global_template = 721 js_global_template =
722 Handle<ObjectTemplateInfo>::cast(proto_template); 722 Handle<ObjectTemplateInfo>::cast(proto_template);
723 } 723 }
724 } 724 }
725 725
726 if (js_global_template.is_null()) { 726 if (js_global_template.is_null()) {
727 Handle<String> name = Handle<String>(heap()->empty_symbol()); 727 Handle<String> name = Handle<String>(heap()->empty_string());
728 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin( 728 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin(
729 Builtins::kIllegal)); 729 Builtins::kIllegal));
730 js_global_function = 730 js_global_function =
731 factory()->NewFunction(name, JS_GLOBAL_OBJECT_TYPE, 731 factory()->NewFunction(name, JS_GLOBAL_OBJECT_TYPE,
732 JSGlobalObject::kSize, code, true); 732 JSGlobalObject::kSize, code, true);
733 // Change the constructor property of the prototype of the 733 // Change the constructor property of the prototype of the
734 // hidden global function to refer to the Object function. 734 // hidden global function to refer to the Object function.
735 Handle<JSObject> prototype = 735 Handle<JSObject> prototype =
736 Handle<JSObject>( 736 Handle<JSObject>(
737 JSObject::cast(js_global_function->instance_prototype())); 737 JSObject::cast(js_global_function->instance_prototype()));
738 CHECK_NOT_EMPTY_HANDLE(isolate(), 738 CHECK_NOT_EMPTY_HANDLE(isolate(),
739 JSObject::SetLocalPropertyIgnoreAttributes( 739 JSObject::SetLocalPropertyIgnoreAttributes(
740 prototype, factory()->constructor_symbol(), 740 prototype, factory()->constructor_string(),
741 isolate()->object_function(), NONE)); 741 isolate()->object_function(), NONE));
742 } else { 742 } else {
743 Handle<FunctionTemplateInfo> js_global_constructor( 743 Handle<FunctionTemplateInfo> js_global_constructor(
744 FunctionTemplateInfo::cast(js_global_template->constructor())); 744 FunctionTemplateInfo::cast(js_global_template->constructor()));
745 js_global_function = 745 js_global_function =
746 factory()->CreateApiFunction(js_global_constructor, 746 factory()->CreateApiFunction(js_global_constructor,
747 factory()->InnerGlobalObject); 747 factory()->InnerGlobalObject);
748 } 748 }
749 749
750 js_global_function->initial_map()->set_is_hidden_prototype(); 750 js_global_function->initial_map()->set_is_hidden_prototype();
751 js_global_function->initial_map()->set_dictionary_map(true); 751 js_global_function->initial_map()->set_dictionary_map(true);
752 Handle<GlobalObject> inner_global = 752 Handle<GlobalObject> inner_global =
753 factory()->NewGlobalObject(js_global_function); 753 factory()->NewGlobalObject(js_global_function);
754 if (inner_global_out != NULL) { 754 if (inner_global_out != NULL) {
755 *inner_global_out = inner_global; 755 *inner_global_out = inner_global;
756 } 756 }
757 757
758 // Step 2: create or re-initialize the global proxy object. 758 // Step 2: create or re-initialize the global proxy object.
759 Handle<JSFunction> global_proxy_function; 759 Handle<JSFunction> global_proxy_function;
760 if (global_template.IsEmpty()) { 760 if (global_template.IsEmpty()) {
761 Handle<String> name = Handle<String>(heap()->empty_symbol()); 761 Handle<String> name = Handle<String>(heap()->empty_string());
762 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin( 762 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin(
763 Builtins::kIllegal)); 763 Builtins::kIllegal));
764 global_proxy_function = 764 global_proxy_function =
765 factory()->NewFunction(name, JS_GLOBAL_PROXY_TYPE, 765 factory()->NewFunction(name, JS_GLOBAL_PROXY_TYPE,
766 JSGlobalProxy::kSize, code, true); 766 JSGlobalProxy::kSize, code, true);
767 } else { 767 } else {
768 Handle<ObjectTemplateInfo> data = 768 Handle<ObjectTemplateInfo> data =
769 v8::Utils::OpenHandle(*global_template); 769 v8::Utils::OpenHandle(*global_template);
770 Handle<FunctionTemplateInfo> global_constructor( 770 Handle<FunctionTemplateInfo> global_constructor(
771 FunctionTemplateInfo::cast(data->constructor())); 771 FunctionTemplateInfo::cast(data->constructor()));
772 global_proxy_function = 772 global_proxy_function =
773 factory()->CreateApiFunction(global_constructor, 773 factory()->CreateApiFunction(global_constructor,
774 factory()->OuterGlobalObject); 774 factory()->OuterGlobalObject);
775 } 775 }
776 776
777 Handle<String> global_name = factory()->LookupOneByteSymbol( 777 Handle<String> global_name = factory()->InternalizeOneByteString(
778 STATIC_ASCII_VECTOR("global")); 778 STATIC_ASCII_VECTOR("global"));
779 global_proxy_function->shared()->set_instance_class_name(*global_name); 779 global_proxy_function->shared()->set_instance_class_name(*global_name);
780 global_proxy_function->initial_map()->set_is_access_check_needed(true); 780 global_proxy_function->initial_map()->set_is_access_check_needed(true);
781 781
782 // Set global_proxy.__proto__ to js_global after ConfigureGlobalObjects 782 // Set global_proxy.__proto__ to js_global after ConfigureGlobalObjects
783 // Return the global proxy. 783 // Return the global proxy.
784 784
785 if (global_object.location() != NULL) { 785 if (global_object.location() != NULL) {
786 ASSERT(global_object->IsJSGlobalProxy()); 786 ASSERT(global_object->IsJSGlobalProxy());
787 return ReinitializeJSGlobalProxy( 787 return ReinitializeJSGlobalProxy(
(...skipping 20 matching lines...) Expand all
808 void Genesis::HookUpInnerGlobal(Handle<GlobalObject> inner_global) { 808 void Genesis::HookUpInnerGlobal(Handle<GlobalObject> inner_global) {
809 Handle<GlobalObject> inner_global_from_snapshot( 809 Handle<GlobalObject> inner_global_from_snapshot(
810 GlobalObject::cast(native_context_->extension())); 810 GlobalObject::cast(native_context_->extension()));
811 Handle<JSBuiltinsObject> builtins_global(native_context_->builtins()); 811 Handle<JSBuiltinsObject> builtins_global(native_context_->builtins());
812 native_context_->set_extension(*inner_global); 812 native_context_->set_extension(*inner_global);
813 native_context_->set_global_object(*inner_global); 813 native_context_->set_global_object(*inner_global);
814 native_context_->set_security_token(*inner_global); 814 native_context_->set_security_token(*inner_global);
815 static const PropertyAttributes attributes = 815 static const PropertyAttributes attributes =
816 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); 816 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
817 ForceSetProperty(builtins_global, 817 ForceSetProperty(builtins_global,
818 factory()->LookupOneByteSymbol( 818 factory()->InternalizeOneByteString(
819 STATIC_ASCII_VECTOR("global")), 819 STATIC_ASCII_VECTOR("global")),
820 inner_global, 820 inner_global,
821 attributes); 821 attributes);
822 // Set up the reference from the global object to the builtins object. 822 // Set up the reference from the global object to the builtins object.
823 JSGlobalObject::cast(*inner_global)->set_builtins(*builtins_global); 823 JSGlobalObject::cast(*inner_global)->set_builtins(*builtins_global);
824 TransferNamedProperties(inner_global_from_snapshot, inner_global); 824 TransferNamedProperties(inner_global_from_snapshot, inner_global);
825 TransferIndexedProperties(inner_global_from_snapshot, inner_global); 825 TransferIndexedProperties(inner_global_from_snapshot, inner_global);
826 } 826 }
827 827
828 828
(...skipping 11 matching lines...) Expand all
840 // Security setup: Set the security token of the global object to 840 // Security setup: Set the security token of the global object to
841 // its the inner global. This makes the security check between two 841 // its the inner global. This makes the security check between two
842 // different contexts fail by default even in case of global 842 // different contexts fail by default even in case of global
843 // object reinitialization. 843 // object reinitialization.
844 native_context()->set_security_token(*inner_global); 844 native_context()->set_security_token(*inner_global);
845 845
846 Isolate* isolate = inner_global->GetIsolate(); 846 Isolate* isolate = inner_global->GetIsolate();
847 Factory* factory = isolate->factory(); 847 Factory* factory = isolate->factory();
848 Heap* heap = isolate->heap(); 848 Heap* heap = isolate->heap();
849 849
850 Handle<String> object_name = Handle<String>(heap->Object_symbol()); 850 Handle<String> object_name = Handle<String>(heap->Object_string());
851 CHECK_NOT_EMPTY_HANDLE(isolate, 851 CHECK_NOT_EMPTY_HANDLE(isolate,
852 JSObject::SetLocalPropertyIgnoreAttributes( 852 JSObject::SetLocalPropertyIgnoreAttributes(
853 inner_global, object_name, 853 inner_global, object_name,
854 isolate->object_function(), DONT_ENUM)); 854 isolate->object_function(), DONT_ENUM));
855 855
856 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); 856 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object());
857 857
858 // Install global Function object 858 // Install global Function object
859 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, 859 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize,
860 empty_function, Builtins::kIllegal, true); // ECMA native. 860 empty_function, Builtins::kIllegal, true); // ECMA native.
(...skipping 15 matching lines...) Expand all
876 Handle<DescriptorArray> array_descriptors( 876 Handle<DescriptorArray> array_descriptors(
877 factory->NewDescriptorArray(0, 1)); 877 factory->NewDescriptorArray(0, 1));
878 DescriptorArray::WhitenessWitness witness(*array_descriptors); 878 DescriptorArray::WhitenessWitness witness(*array_descriptors);
879 879
880 Handle<Foreign> array_length(factory->NewForeign(&Accessors::ArrayLength)); 880 Handle<Foreign> array_length(factory->NewForeign(&Accessors::ArrayLength));
881 PropertyAttributes attribs = static_cast<PropertyAttributes>( 881 PropertyAttributes attribs = static_cast<PropertyAttributes>(
882 DONT_ENUM | DONT_DELETE); 882 DONT_ENUM | DONT_DELETE);
883 initial_map->set_instance_descriptors(*array_descriptors); 883 initial_map->set_instance_descriptors(*array_descriptors);
884 884
885 { // Add length. 885 { // Add length.
886 CallbacksDescriptor d(*factory->length_symbol(), *array_length, attribs); 886 CallbacksDescriptor d(*factory->length_string(), *array_length, attribs);
887 array_function->initial_map()->AppendDescriptor(&d, witness); 887 array_function->initial_map()->AppendDescriptor(&d, witness);
888 } 888 }
889 889
890 // array_function is used internally. JS code creating array object should 890 // array_function is used internally. JS code creating array object should
891 // search for the 'Array' property on the global object and use that one 891 // search for the 'Array' property on the global object and use that one
892 // as the constructor. 'Array' property on a global object can be 892 // as the constructor. 'Array' property on a global object can be
893 // overwritten by JS code. 893 // overwritten by JS code.
894 native_context()->set_array_function(*array_function); 894 native_context()->set_array_function(*array_function);
895 } 895 }
896 896
(...skipping 28 matching lines...) Expand all
925 factory->NewDescriptorArray(0, 1)); 925 factory->NewDescriptorArray(0, 1));
926 DescriptorArray::WhitenessWitness witness(*string_descriptors); 926 DescriptorArray::WhitenessWitness witness(*string_descriptors);
927 927
928 Handle<Foreign> string_length( 928 Handle<Foreign> string_length(
929 factory->NewForeign(&Accessors::StringLength)); 929 factory->NewForeign(&Accessors::StringLength));
930 PropertyAttributes attribs = static_cast<PropertyAttributes>( 930 PropertyAttributes attribs = static_cast<PropertyAttributes>(
931 DONT_ENUM | DONT_DELETE | READ_ONLY); 931 DONT_ENUM | DONT_DELETE | READ_ONLY);
932 string_map->set_instance_descriptors(*string_descriptors); 932 string_map->set_instance_descriptors(*string_descriptors);
933 933
934 { // Add length. 934 { // Add length.
935 CallbacksDescriptor d(*factory->length_symbol(), *string_length, attribs); 935 CallbacksDescriptor d(*factory->length_string(), *string_length, attribs);
936 string_map->AppendDescriptor(&d, witness); 936 string_map->AppendDescriptor(&d, witness);
937 } 937 }
938 } 938 }
939 939
940 { // --- D a t e --- 940 { // --- D a t e ---
941 // Builtin functions for Date.prototype. 941 // Builtin functions for Date.prototype.
942 Handle<JSFunction> date_fun = 942 Handle<JSFunction> date_fun =
943 InstallFunction(global, "Date", JS_DATE_TYPE, JSDate::kSize, 943 InstallFunction(global, "Date", JS_DATE_TYPE, JSDate::kSize,
944 isolate->initial_object_prototype(), 944 isolate->initial_object_prototype(),
945 Builtins::kIllegal, true); 945 Builtins::kIllegal, true);
(...skipping 16 matching lines...) Expand all
962 ASSERT_EQ(0, initial_map->inobject_properties()); 962 ASSERT_EQ(0, initial_map->inobject_properties());
963 963
964 PropertyAttributes final = 964 PropertyAttributes final =
965 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 965 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
966 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(0, 5); 966 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(0, 5);
967 DescriptorArray::WhitenessWitness witness(*descriptors); 967 DescriptorArray::WhitenessWitness witness(*descriptors);
968 initial_map->set_instance_descriptors(*descriptors); 968 initial_map->set_instance_descriptors(*descriptors);
969 969
970 { 970 {
971 // ECMA-262, section 15.10.7.1. 971 // ECMA-262, section 15.10.7.1.
972 FieldDescriptor field(heap->source_symbol(), 972 FieldDescriptor field(heap->source_string(),
973 JSRegExp::kSourceFieldIndex, 973 JSRegExp::kSourceFieldIndex,
974 final); 974 final);
975 initial_map->AppendDescriptor(&field, witness); 975 initial_map->AppendDescriptor(&field, witness);
976 } 976 }
977 { 977 {
978 // ECMA-262, section 15.10.7.2. 978 // ECMA-262, section 15.10.7.2.
979 FieldDescriptor field(heap->global_symbol(), 979 FieldDescriptor field(heap->global_string(),
980 JSRegExp::kGlobalFieldIndex, 980 JSRegExp::kGlobalFieldIndex,
981 final); 981 final);
982 initial_map->AppendDescriptor(&field, witness); 982 initial_map->AppendDescriptor(&field, witness);
983 } 983 }
984 { 984 {
985 // ECMA-262, section 15.10.7.3. 985 // ECMA-262, section 15.10.7.3.
986 FieldDescriptor field(heap->ignore_case_symbol(), 986 FieldDescriptor field(heap->ignore_case_string(),
987 JSRegExp::kIgnoreCaseFieldIndex, 987 JSRegExp::kIgnoreCaseFieldIndex,
988 final); 988 final);
989 initial_map->AppendDescriptor(&field, witness); 989 initial_map->AppendDescriptor(&field, witness);
990 } 990 }
991 { 991 {
992 // ECMA-262, section 15.10.7.4. 992 // ECMA-262, section 15.10.7.4.
993 FieldDescriptor field(heap->multiline_symbol(), 993 FieldDescriptor field(heap->multiline_string(),
994 JSRegExp::kMultilineFieldIndex, 994 JSRegExp::kMultilineFieldIndex,
995 final); 995 final);
996 initial_map->AppendDescriptor(&field, witness); 996 initial_map->AppendDescriptor(&field, witness);
997 } 997 }
998 { 998 {
999 // ECMA-262, section 15.10.7.5. 999 // ECMA-262, section 15.10.7.5.
1000 PropertyAttributes writable = 1000 PropertyAttributes writable =
1001 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); 1001 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE);
1002 FieldDescriptor field(heap->last_index_symbol(), 1002 FieldDescriptor field(heap->last_index_string(),
1003 JSRegExp::kLastIndexFieldIndex, 1003 JSRegExp::kLastIndexFieldIndex,
1004 writable); 1004 writable);
1005 initial_map->AppendDescriptor(&field, witness); 1005 initial_map->AppendDescriptor(&field, witness);
1006 } 1006 }
1007 1007
1008 initial_map->set_inobject_properties(5); 1008 initial_map->set_inobject_properties(5);
1009 initial_map->set_pre_allocated_property_fields(5); 1009 initial_map->set_pre_allocated_property_fields(5);
1010 initial_map->set_unused_property_fields(0); 1010 initial_map->set_unused_property_fields(0);
1011 initial_map->set_instance_size( 1011 initial_map->set_instance_size(
1012 initial_map->instance_size() + 5 * kPointerSize); 1012 initial_map->instance_size() + 5 * kPointerSize);
1013 initial_map->set_visitor_id(StaticVisitorBase::GetVisitorId(*initial_map)); 1013 initial_map->set_visitor_id(StaticVisitorBase::GetVisitorId(*initial_map));
1014 1014
1015 // RegExp prototype object is itself a RegExp. 1015 // RegExp prototype object is itself a RegExp.
1016 Handle<Map> proto_map = factory->CopyMap(initial_map); 1016 Handle<Map> proto_map = factory->CopyMap(initial_map);
1017 proto_map->set_prototype(native_context()->initial_object_prototype()); 1017 proto_map->set_prototype(native_context()->initial_object_prototype());
1018 Handle<JSObject> proto = factory->NewJSObjectFromMap(proto_map); 1018 Handle<JSObject> proto = factory->NewJSObjectFromMap(proto_map);
1019 proto->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex, 1019 proto->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex,
1020 heap->query_colon_symbol()); 1020 heap->query_colon_string());
1021 proto->InObjectPropertyAtPut(JSRegExp::kGlobalFieldIndex, 1021 proto->InObjectPropertyAtPut(JSRegExp::kGlobalFieldIndex,
1022 heap->false_value()); 1022 heap->false_value());
1023 proto->InObjectPropertyAtPut(JSRegExp::kIgnoreCaseFieldIndex, 1023 proto->InObjectPropertyAtPut(JSRegExp::kIgnoreCaseFieldIndex,
1024 heap->false_value()); 1024 heap->false_value());
1025 proto->InObjectPropertyAtPut(JSRegExp::kMultilineFieldIndex, 1025 proto->InObjectPropertyAtPut(JSRegExp::kMultilineFieldIndex,
1026 heap->false_value()); 1026 heap->false_value());
1027 proto->InObjectPropertyAtPut(JSRegExp::kLastIndexFieldIndex, 1027 proto->InObjectPropertyAtPut(JSRegExp::kLastIndexFieldIndex,
1028 Smi::FromInt(0), 1028 Smi::FromInt(0),
1029 SKIP_WRITE_BARRIER); // It's a Smi. 1029 SKIP_WRITE_BARRIER); // It's a Smi.
1030 initial_map->set_prototype(*proto); 1030 initial_map->set_prototype(*proto);
(...skipping 16 matching lines...) Expand all
1047 CHECK_NOT_EMPTY_HANDLE(isolate, 1047 CHECK_NOT_EMPTY_HANDLE(isolate,
1048 JSObject::SetLocalPropertyIgnoreAttributes( 1048 JSObject::SetLocalPropertyIgnoreAttributes(
1049 global, name, json_object, DONT_ENUM)); 1049 global, name, json_object, DONT_ENUM));
1050 native_context()->set_json_object(*json_object); 1050 native_context()->set_json_object(*json_object);
1051 } 1051 }
1052 1052
1053 { // --- arguments_boilerplate_ 1053 { // --- arguments_boilerplate_
1054 // Make sure we can recognize argument objects at runtime. 1054 // Make sure we can recognize argument objects at runtime.
1055 // This is done by introducing an anonymous function with 1055 // This is done by introducing an anonymous function with
1056 // class_name equals 'Arguments'. 1056 // class_name equals 'Arguments'.
1057 Handle<String> symbol = factory->LookupOneByteSymbol( 1057 Handle<String> arguments_string = factory->InternalizeOneByteString(
1058 STATIC_ASCII_VECTOR("Arguments")); 1058 STATIC_ASCII_VECTOR("Arguments"));
1059 Handle<Code> code = Handle<Code>( 1059 Handle<Code> code = Handle<Code>(
1060 isolate->builtins()->builtin(Builtins::kIllegal)); 1060 isolate->builtins()->builtin(Builtins::kIllegal));
1061 Handle<JSObject> prototype = 1061 Handle<JSObject> prototype =
1062 Handle<JSObject>( 1062 Handle<JSObject>(
1063 JSObject::cast(native_context()->object_function()->prototype())); 1063 JSObject::cast(native_context()->object_function()->prototype()));
1064 1064
1065 Handle<JSFunction> function = 1065 Handle<JSFunction> function =
1066 factory->NewFunctionWithPrototype(symbol, 1066 factory->NewFunctionWithPrototype(arguments_string,
1067 JS_OBJECT_TYPE, 1067 JS_OBJECT_TYPE,
1068 JSObject::kHeaderSize, 1068 JSObject::kHeaderSize,
1069 prototype, 1069 prototype,
1070 code, 1070 code,
1071 false); 1071 false);
1072 ASSERT(!function->has_initial_map()); 1072 ASSERT(!function->has_initial_map());
1073 function->shared()->set_instance_class_name(*symbol); 1073 function->shared()->set_instance_class_name(*arguments_string);
1074 function->shared()->set_expected_nof_properties(2); 1074 function->shared()->set_expected_nof_properties(2);
1075 Handle<JSObject> result = factory->NewJSObject(function); 1075 Handle<JSObject> result = factory->NewJSObject(function);
1076 1076
1077 native_context()->set_arguments_boilerplate(*result); 1077 native_context()->set_arguments_boilerplate(*result);
1078 // Note: length must be added as the first property and 1078 // Note: length must be added as the first property and
1079 // callee must be added as the second property. 1079 // callee must be added as the second property.
1080 CHECK_NOT_EMPTY_HANDLE(isolate, 1080 CHECK_NOT_EMPTY_HANDLE(isolate,
1081 JSObject::SetLocalPropertyIgnoreAttributes( 1081 JSObject::SetLocalPropertyIgnoreAttributes(
1082 result, factory->length_symbol(), 1082 result, factory->length_string(),
1083 factory->undefined_value(), DONT_ENUM)); 1083 factory->undefined_value(), DONT_ENUM));
1084 CHECK_NOT_EMPTY_HANDLE(isolate, 1084 CHECK_NOT_EMPTY_HANDLE(isolate,
1085 JSObject::SetLocalPropertyIgnoreAttributes( 1085 JSObject::SetLocalPropertyIgnoreAttributes(
1086 result, factory->callee_symbol(), 1086 result, factory->callee_string(),
1087 factory->undefined_value(), DONT_ENUM)); 1087 factory->undefined_value(), DONT_ENUM));
1088 1088
1089 #ifdef DEBUG 1089 #ifdef DEBUG
1090 LookupResult lookup(isolate); 1090 LookupResult lookup(isolate);
1091 result->LocalLookup(heap->callee_symbol(), &lookup); 1091 result->LocalLookup(heap->callee_string(), &lookup);
1092 ASSERT(lookup.IsField()); 1092 ASSERT(lookup.IsField());
1093 ASSERT(lookup.GetFieldIndex().field_index() == Heap::kArgumentsCalleeIndex); 1093 ASSERT(lookup.GetFieldIndex().field_index() == Heap::kArgumentsCalleeIndex);
1094 1094
1095 result->LocalLookup(heap->length_symbol(), &lookup); 1095 result->LocalLookup(heap->length_string(), &lookup);
1096 ASSERT(lookup.IsField()); 1096 ASSERT(lookup.IsField());
1097 ASSERT(lookup.GetFieldIndex().field_index() == Heap::kArgumentsLengthIndex); 1097 ASSERT(lookup.GetFieldIndex().field_index() == Heap::kArgumentsLengthIndex);
1098 1098
1099 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsCalleeIndex); 1099 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsCalleeIndex);
1100 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex); 1100 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex);
1101 1101
1102 // Check the state of the object. 1102 // Check the state of the object.
1103 ASSERT(result->HasFastProperties()); 1103 ASSERT(result->HasFastProperties());
1104 ASSERT(result->HasFastObjectElements()); 1104 ASSERT(result->HasFastObjectElements());
1105 #endif 1105 #endif
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 1146
1147 // Create the map. Allocate one in-object field for length. 1147 // Create the map. Allocate one in-object field for length.
1148 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, 1148 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE,
1149 Heap::kArgumentsObjectSizeStrict); 1149 Heap::kArgumentsObjectSizeStrict);
1150 // Create the descriptor array for the arguments object. 1150 // Create the descriptor array for the arguments object.
1151 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(0, 3); 1151 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(0, 3);
1152 DescriptorArray::WhitenessWitness witness(*descriptors); 1152 DescriptorArray::WhitenessWitness witness(*descriptors);
1153 map->set_instance_descriptors(*descriptors); 1153 map->set_instance_descriptors(*descriptors);
1154 1154
1155 { // length 1155 { // length
1156 FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM); 1156 FieldDescriptor d(*factory->length_string(), 0, DONT_ENUM);
1157 map->AppendDescriptor(&d, witness); 1157 map->AppendDescriptor(&d, witness);
1158 } 1158 }
1159 { // callee 1159 { // callee
1160 CallbacksDescriptor d(*factory->callee_symbol(), 1160 CallbacksDescriptor d(*factory->callee_string(),
1161 *callee, 1161 *callee,
1162 attributes); 1162 attributes);
1163 map->AppendDescriptor(&d, witness); 1163 map->AppendDescriptor(&d, witness);
1164 } 1164 }
1165 { // caller 1165 { // caller
1166 CallbacksDescriptor d(*factory->caller_symbol(), 1166 CallbacksDescriptor d(*factory->caller_string(),
1167 *caller, 1167 *caller,
1168 attributes); 1168 attributes);
1169 map->AppendDescriptor(&d, witness); 1169 map->AppendDescriptor(&d, witness);
1170 } 1170 }
1171 1171
1172 map->set_function_with_prototype(true); 1172 map->set_function_with_prototype(true);
1173 map->set_prototype(native_context()->object_function()->prototype()); 1173 map->set_prototype(native_context()->object_function()->prototype());
1174 map->set_pre_allocated_property_fields(1); 1174 map->set_pre_allocated_property_fields(1);
1175 map->set_inobject_properties(1); 1175 map->set_inobject_properties(1);
1176 1176
1177 // Copy constructor from the non-strict arguments boilerplate. 1177 // Copy constructor from the non-strict arguments boilerplate.
1178 map->set_constructor( 1178 map->set_constructor(
1179 native_context()->arguments_boilerplate()->map()->constructor()); 1179 native_context()->arguments_boilerplate()->map()->constructor());
1180 1180
1181 // Allocate the arguments boilerplate object. 1181 // Allocate the arguments boilerplate object.
1182 Handle<JSObject> result = factory->NewJSObjectFromMap(map); 1182 Handle<JSObject> result = factory->NewJSObjectFromMap(map);
1183 native_context()->set_strict_mode_arguments_boilerplate(*result); 1183 native_context()->set_strict_mode_arguments_boilerplate(*result);
1184 1184
1185 // Add length property only for strict mode boilerplate. 1185 // Add length property only for strict mode boilerplate.
1186 CHECK_NOT_EMPTY_HANDLE(isolate, 1186 CHECK_NOT_EMPTY_HANDLE(isolate,
1187 JSObject::SetLocalPropertyIgnoreAttributes( 1187 JSObject::SetLocalPropertyIgnoreAttributes(
1188 result, factory->length_symbol(), 1188 result, factory->length_string(),
1189 factory->undefined_value(), DONT_ENUM)); 1189 factory->undefined_value(), DONT_ENUM));
1190 1190
1191 #ifdef DEBUG 1191 #ifdef DEBUG
1192 LookupResult lookup(isolate); 1192 LookupResult lookup(isolate);
1193 result->LocalLookup(heap->length_symbol(), &lookup); 1193 result->LocalLookup(heap->length_string(), &lookup);
1194 ASSERT(lookup.IsField()); 1194 ASSERT(lookup.IsField());
1195 ASSERT(lookup.GetFieldIndex().field_index() == Heap::kArgumentsLengthIndex); 1195 ASSERT(lookup.GetFieldIndex().field_index() == Heap::kArgumentsLengthIndex);
1196 1196
1197 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex); 1197 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex);
1198 1198
1199 // Check the state of the object. 1199 // Check the state of the object.
1200 ASSERT(result->HasFastProperties()); 1200 ASSERT(result->HasFastProperties());
1201 ASSERT(result->HasFastObjectElements()); 1201 ASSERT(result->HasFastObjectElements());
1202 #endif 1202 #endif
1203 } 1203 }
1204 1204
1205 { // --- context extension 1205 { // --- context extension
1206 // Create a function for the context extension objects. 1206 // Create a function for the context extension objects.
1207 Handle<Code> code = Handle<Code>( 1207 Handle<Code> code = Handle<Code>(
1208 isolate->builtins()->builtin(Builtins::kIllegal)); 1208 isolate->builtins()->builtin(Builtins::kIllegal));
1209 Handle<JSFunction> context_extension_fun = 1209 Handle<JSFunction> context_extension_fun =
1210 factory->NewFunction(factory->empty_symbol(), 1210 factory->NewFunction(factory->empty_string(),
1211 JS_CONTEXT_EXTENSION_OBJECT_TYPE, 1211 JS_CONTEXT_EXTENSION_OBJECT_TYPE,
1212 JSObject::kHeaderSize, 1212 JSObject::kHeaderSize,
1213 code, 1213 code,
1214 true); 1214 true);
1215 1215
1216 Handle<String> name = 1216 Handle<String> name = factory->InternalizeOneByteString(
1217 factory->LookupOneByteSymbol(STATIC_ASCII_VECTOR("context_extension")); 1217 STATIC_ASCII_VECTOR("context_extension"));
1218 context_extension_fun->shared()->set_instance_class_name(*name); 1218 context_extension_fun->shared()->set_instance_class_name(*name);
1219 native_context()->set_context_extension_function(*context_extension_fun); 1219 native_context()->set_context_extension_function(*context_extension_fun);
1220 } 1220 }
1221 1221
1222 1222
1223 { 1223 {
1224 // Set up the call-as-function delegate. 1224 // Set up the call-as-function delegate.
1225 Handle<Code> code = 1225 Handle<Code> code =
1226 Handle<Code>(isolate->builtins()->builtin( 1226 Handle<Code>(isolate->builtins()->builtin(
1227 Builtins::kHandleApiCallAsFunction)); 1227 Builtins::kHandleApiCallAsFunction));
1228 Handle<JSFunction> delegate = 1228 Handle<JSFunction> delegate =
1229 factory->NewFunction(factory->empty_symbol(), JS_OBJECT_TYPE, 1229 factory->NewFunction(factory->empty_string(), JS_OBJECT_TYPE,
1230 JSObject::kHeaderSize, code, true); 1230 JSObject::kHeaderSize, code, true);
1231 native_context()->set_call_as_function_delegate(*delegate); 1231 native_context()->set_call_as_function_delegate(*delegate);
1232 delegate->shared()->DontAdaptArguments(); 1232 delegate->shared()->DontAdaptArguments();
1233 } 1233 }
1234 1234
1235 { 1235 {
1236 // Set up the call-as-constructor delegate. 1236 // Set up the call-as-constructor delegate.
1237 Handle<Code> code = 1237 Handle<Code> code =
1238 Handle<Code>(isolate->builtins()->builtin( 1238 Handle<Code>(isolate->builtins()->builtin(
1239 Builtins::kHandleApiCallAsConstructor)); 1239 Builtins::kHandleApiCallAsConstructor));
1240 Handle<JSFunction> delegate = 1240 Handle<JSFunction> delegate =
1241 factory->NewFunction(factory->empty_symbol(), JS_OBJECT_TYPE, 1241 factory->NewFunction(factory->empty_string(), JS_OBJECT_TYPE,
1242 JSObject::kHeaderSize, code, true); 1242 JSObject::kHeaderSize, code, true);
1243 native_context()->set_call_as_constructor_delegate(*delegate); 1243 native_context()->set_call_as_constructor_delegate(*delegate);
1244 delegate->shared()->DontAdaptArguments(); 1244 delegate->shared()->DontAdaptArguments();
1245 } 1245 }
1246 1246
1247 // Initialize the out of memory slot. 1247 // Initialize the out of memory slot.
1248 native_context()->set_out_of_memory(heap->false_value()); 1248 native_context()->set_out_of_memory(heap->false_value());
1249 1249
1250 // Initialize the embedder data slot. 1250 // Initialize the embedder data slot.
1251 Handle<FixedArray> embedder_data = factory->NewFixedArray(2); 1251 Handle<FixedArray> embedder_data = factory->NewFixedArray(2);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 : top_context->global_object()); 1383 : top_context->global_object());
1384 bool has_pending_exception; 1384 bool has_pending_exception;
1385 Execution::Call(fun, receiver, 0, NULL, &has_pending_exception); 1385 Execution::Call(fun, receiver, 0, NULL, &has_pending_exception);
1386 if (has_pending_exception) return false; 1386 if (has_pending_exception) return false;
1387 return true; 1387 return true;
1388 } 1388 }
1389 1389
1390 1390
1391 #define INSTALL_NATIVE(Type, name, var) \ 1391 #define INSTALL_NATIVE(Type, name, var) \
1392 Handle<String> var##_name = \ 1392 Handle<String> var##_name = \
1393 factory()->LookupOneByteSymbol(STATIC_ASCII_VECTOR(name)); \ 1393 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR(name)); \
1394 Object* var##_native = \ 1394 Object* var##_native = \
1395 native_context()->builtins()->GetPropertyNoExceptionThrown( \ 1395 native_context()->builtins()->GetPropertyNoExceptionThrown( \
1396 *var##_name); \ 1396 *var##_name); \
1397 native_context()->set_##var(Type::cast(var##_native)); 1397 native_context()->set_##var(Type::cast(var##_native));
1398 1398
1399 1399
1400 void Genesis::InstallNativeFunctions() { 1400 void Genesis::InstallNativeFunctions() {
1401 HandleScope scope; 1401 HandleScope scope;
1402 INSTALL_NATIVE(JSFunction, "CreateDate", create_date_fun); 1402 INSTALL_NATIVE(JSFunction, "CreateDate", create_date_fun);
1403 INSTALL_NATIVE(JSFunction, "ToNumber", to_number_fun); 1403 INSTALL_NATIVE(JSFunction, "ToNumber", to_number_fun);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 1436
1437 bool Genesis::InstallNatives() { 1437 bool Genesis::InstallNatives() {
1438 HandleScope scope; 1438 HandleScope scope;
1439 1439
1440 // Create a function for the builtins object. Allocate space for the 1440 // Create a function for the builtins object. Allocate space for the
1441 // JavaScript builtins, a reference to the builtins object 1441 // JavaScript builtins, a reference to the builtins object
1442 // (itself) and a reference to the native_context directly in the object. 1442 // (itself) and a reference to the native_context directly in the object.
1443 Handle<Code> code = Handle<Code>( 1443 Handle<Code> code = Handle<Code>(
1444 isolate()->builtins()->builtin(Builtins::kIllegal)); 1444 isolate()->builtins()->builtin(Builtins::kIllegal));
1445 Handle<JSFunction> builtins_fun = 1445 Handle<JSFunction> builtins_fun =
1446 factory()->NewFunction(factory()->empty_symbol(), 1446 factory()->NewFunction(factory()->empty_string(),
1447 JS_BUILTINS_OBJECT_TYPE, 1447 JS_BUILTINS_OBJECT_TYPE,
1448 JSBuiltinsObject::kSize, code, true); 1448 JSBuiltinsObject::kSize, code, true);
1449 1449
1450 Handle<String> name = 1450 Handle<String> name =
1451 factory()->LookupOneByteSymbol(STATIC_ASCII_VECTOR("builtins")); 1451 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("builtins"));
1452 builtins_fun->shared()->set_instance_class_name(*name); 1452 builtins_fun->shared()->set_instance_class_name(*name);
1453 builtins_fun->initial_map()->set_dictionary_map(true); 1453 builtins_fun->initial_map()->set_dictionary_map(true);
1454 builtins_fun->initial_map()->set_prototype(heap()->null_value()); 1454 builtins_fun->initial_map()->set_prototype(heap()->null_value());
1455 1455
1456 // Allocate the builtins object. 1456 // Allocate the builtins object.
1457 Handle<JSBuiltinsObject> builtins = 1457 Handle<JSBuiltinsObject> builtins =
1458 Handle<JSBuiltinsObject>::cast(factory()->NewGlobalObject(builtins_fun)); 1458 Handle<JSBuiltinsObject>::cast(factory()->NewGlobalObject(builtins_fun));
1459 builtins->set_builtins(*builtins); 1459 builtins->set_builtins(*builtins);
1460 builtins->set_native_context(*native_context()); 1460 builtins->set_native_context(*native_context());
1461 builtins->set_global_context(*native_context()); 1461 builtins->set_global_context(*native_context());
1462 builtins->set_global_receiver(*builtins); 1462 builtins->set_global_receiver(*builtins);
1463 1463
1464 // Set up the 'global' properties of the builtins object. The 1464 // Set up the 'global' properties of the builtins object. The
1465 // 'global' property that refers to the global object is the only 1465 // 'global' property that refers to the global object is the only
1466 // way to get from code running in the builtins context to the 1466 // way to get from code running in the builtins context to the
1467 // global object. 1467 // global object.
1468 static const PropertyAttributes attributes = 1468 static const PropertyAttributes attributes =
1469 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); 1469 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
1470 Handle<String> global_symbol = 1470 Handle<String> global_string =
1471 factory()->LookupOneByteSymbol(STATIC_ASCII_VECTOR("global")); 1471 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("global"));
1472 Handle<Object> global_obj(native_context()->global_object()); 1472 Handle<Object> global_obj(native_context()->global_object());
1473 CHECK_NOT_EMPTY_HANDLE(isolate(), 1473 CHECK_NOT_EMPTY_HANDLE(isolate(),
1474 JSObject::SetLocalPropertyIgnoreAttributes( 1474 JSObject::SetLocalPropertyIgnoreAttributes(
1475 builtins, global_symbol, global_obj, attributes)); 1475 builtins, global_string, global_obj, attributes));
1476 1476
1477 // Set up the reference from the global object to the builtins object. 1477 // Set up the reference from the global object to the builtins object.
1478 JSGlobalObject::cast(native_context()->global_object())-> 1478 JSGlobalObject::cast(native_context()->global_object())->
1479 set_builtins(*builtins); 1479 set_builtins(*builtins);
1480 1480
1481 // Create a bridge function that has context in the native context. 1481 // Create a bridge function that has context in the native context.
1482 Handle<JSFunction> bridge = 1482 Handle<JSFunction> bridge =
1483 factory()->NewFunction(factory()->empty_symbol(), 1483 factory()->NewFunction(factory()->empty_string(),
1484 factory()->undefined_value()); 1484 factory()->undefined_value());
1485 ASSERT(bridge->context() == *isolate()->native_context()); 1485 ASSERT(bridge->context() == *isolate()->native_context());
1486 1486
1487 // Allocate the builtins context. 1487 // Allocate the builtins context.
1488 Handle<Context> context = 1488 Handle<Context> context =
1489 factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, bridge); 1489 factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, bridge);
1490 context->set_global_object(*builtins); // override builtins global object 1490 context->set_global_object(*builtins); // override builtins global object
1491 1491
1492 native_context()->set_runtime_context(*context); 1492 native_context()->set_runtime_context(*context);
1493 1493
(...skipping 10 matching lines...) Expand all
1504 1504
1505 Handle<Map> script_map = Handle<Map>(script_fun->initial_map()); 1505 Handle<Map> script_map = Handle<Map>(script_fun->initial_map());
1506 1506
1507 Handle<DescriptorArray> script_descriptors( 1507 Handle<DescriptorArray> script_descriptors(
1508 factory()->NewDescriptorArray(0, 13)); 1508 factory()->NewDescriptorArray(0, 13));
1509 DescriptorArray::WhitenessWitness witness(*script_descriptors); 1509 DescriptorArray::WhitenessWitness witness(*script_descriptors);
1510 1510
1511 Handle<Foreign> script_source( 1511 Handle<Foreign> script_source(
1512 factory()->NewForeign(&Accessors::ScriptSource)); 1512 factory()->NewForeign(&Accessors::ScriptSource));
1513 Handle<Foreign> script_name(factory()->NewForeign(&Accessors::ScriptName)); 1513 Handle<Foreign> script_name(factory()->NewForeign(&Accessors::ScriptName));
1514 Handle<String> id_symbol(factory()->LookupOneByteSymbol( 1514 Handle<String> id_string(factory()->InternalizeOneByteString(
1515 STATIC_ASCII_VECTOR("id"))); 1515 STATIC_ASCII_VECTOR("id")));
1516 Handle<Foreign> script_id(factory()->NewForeign(&Accessors::ScriptId)); 1516 Handle<Foreign> script_id(factory()->NewForeign(&Accessors::ScriptId));
1517 Handle<String> line_offset_symbol( 1517 Handle<String> line_offset_string(
1518 factory()->LookupOneByteSymbol(STATIC_ASCII_VECTOR("line_offset"))); 1518 factory()->InternalizeOneByteString(
1519 STATIC_ASCII_VECTOR("line_offset")));
1519 Handle<Foreign> script_line_offset( 1520 Handle<Foreign> script_line_offset(
1520 factory()->NewForeign(&Accessors::ScriptLineOffset)); 1521 factory()->NewForeign(&Accessors::ScriptLineOffset));
1521 Handle<String> column_offset_symbol( 1522 Handle<String> column_offset_string(
1522 factory()->LookupOneByteSymbol(STATIC_ASCII_VECTOR("column_offset"))); 1523 factory()->InternalizeOneByteString(
1524 STATIC_ASCII_VECTOR("column_offset")));
1523 Handle<Foreign> script_column_offset( 1525 Handle<Foreign> script_column_offset(
1524 factory()->NewForeign(&Accessors::ScriptColumnOffset)); 1526 factory()->NewForeign(&Accessors::ScriptColumnOffset));
1525 Handle<String> data_symbol(factory()->LookupOneByteSymbol( 1527 Handle<String> data_string(factory()->InternalizeOneByteString(
1526 STATIC_ASCII_VECTOR("data"))); 1528 STATIC_ASCII_VECTOR("data")));
1527 Handle<Foreign> script_data(factory()->NewForeign(&Accessors::ScriptData)); 1529 Handle<Foreign> script_data(factory()->NewForeign(&Accessors::ScriptData));
1528 Handle<String> type_symbol(factory()->LookupOneByteSymbol( 1530 Handle<String> type_string(factory()->InternalizeOneByteString(
1529 STATIC_ASCII_VECTOR("type"))); 1531 STATIC_ASCII_VECTOR("type")));
1530 Handle<Foreign> script_type(factory()->NewForeign(&Accessors::ScriptType)); 1532 Handle<Foreign> script_type(factory()->NewForeign(&Accessors::ScriptType));
1531 Handle<String> compilation_type_symbol( 1533 Handle<String> compilation_type_string(
1532 factory()->LookupOneByteSymbol( 1534 factory()->InternalizeOneByteString(
1533 STATIC_ASCII_VECTOR("compilation_type"))); 1535 STATIC_ASCII_VECTOR("compilation_type")));
1534 Handle<Foreign> script_compilation_type( 1536 Handle<Foreign> script_compilation_type(
1535 factory()->NewForeign(&Accessors::ScriptCompilationType)); 1537 factory()->NewForeign(&Accessors::ScriptCompilationType));
1536 Handle<String> line_ends_symbol(factory()->LookupOneByteSymbol( 1538 Handle<String> line_ends_string(factory()->InternalizeOneByteString(
1537 STATIC_ASCII_VECTOR("line_ends"))); 1539 STATIC_ASCII_VECTOR("line_ends")));
1538 Handle<Foreign> script_line_ends( 1540 Handle<Foreign> script_line_ends(
1539 factory()->NewForeign(&Accessors::ScriptLineEnds)); 1541 factory()->NewForeign(&Accessors::ScriptLineEnds));
1540 Handle<String> context_data_symbol( 1542 Handle<String> context_data_string(
1541 factory()->LookupOneByteSymbol(STATIC_ASCII_VECTOR("context_data"))); 1543 factory()->InternalizeOneByteString(
1544 STATIC_ASCII_VECTOR("context_data")));
1542 Handle<Foreign> script_context_data( 1545 Handle<Foreign> script_context_data(
1543 factory()->NewForeign(&Accessors::ScriptContextData)); 1546 factory()->NewForeign(&Accessors::ScriptContextData));
1544 Handle<String> eval_from_script_symbol( 1547 Handle<String> eval_from_script_string(
1545 factory()->LookupOneByteSymbol( 1548 factory()->InternalizeOneByteString(
1546 STATIC_ASCII_VECTOR("eval_from_script"))); 1549 STATIC_ASCII_VECTOR("eval_from_script")));
1547 Handle<Foreign> script_eval_from_script( 1550 Handle<Foreign> script_eval_from_script(
1548 factory()->NewForeign(&Accessors::ScriptEvalFromScript)); 1551 factory()->NewForeign(&Accessors::ScriptEvalFromScript));
1549 Handle<String> eval_from_script_position_symbol( 1552 Handle<String> eval_from_script_position_string(
1550 factory()->LookupOneByteSymbol( 1553 factory()->InternalizeOneByteString(
1551 STATIC_ASCII_VECTOR("eval_from_script_position"))); 1554 STATIC_ASCII_VECTOR("eval_from_script_position")));
1552 Handle<Foreign> script_eval_from_script_position( 1555 Handle<Foreign> script_eval_from_script_position(
1553 factory()->NewForeign(&Accessors::ScriptEvalFromScriptPosition)); 1556 factory()->NewForeign(&Accessors::ScriptEvalFromScriptPosition));
1554 Handle<String> eval_from_function_name_symbol( 1557 Handle<String> eval_from_function_name_string(
1555 factory()->LookupOneByteSymbol( 1558 factory()->InternalizeOneByteString(
1556 STATIC_ASCII_VECTOR("eval_from_function_name"))); 1559 STATIC_ASCII_VECTOR("eval_from_function_name")));
1557 Handle<Foreign> script_eval_from_function_name( 1560 Handle<Foreign> script_eval_from_function_name(
1558 factory()->NewForeign(&Accessors::ScriptEvalFromFunctionName)); 1561 factory()->NewForeign(&Accessors::ScriptEvalFromFunctionName));
1559 PropertyAttributes attribs = 1562 PropertyAttributes attribs =
1560 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 1563 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
1561 script_map->set_instance_descriptors(*script_descriptors); 1564 script_map->set_instance_descriptors(*script_descriptors);
1562 1565
1563 { 1566 {
1564 CallbacksDescriptor d( 1567 CallbacksDescriptor d(
1565 *factory()->source_symbol(), *script_source, attribs); 1568 *factory()->source_string(), *script_source, attribs);
1566 script_map->AppendDescriptor(&d, witness); 1569 script_map->AppendDescriptor(&d, witness);
1567 } 1570 }
1568 1571
1569 { 1572 {
1570 CallbacksDescriptor d(*factory()->name_symbol(), *script_name, attribs); 1573 CallbacksDescriptor d(*factory()->name_string(), *script_name, attribs);
1571 script_map->AppendDescriptor(&d, witness); 1574 script_map->AppendDescriptor(&d, witness);
1572 } 1575 }
1573 1576
1574 { 1577 {
1575 CallbacksDescriptor d(*id_symbol, *script_id, attribs); 1578 CallbacksDescriptor d(*id_string, *script_id, attribs);
1576 script_map->AppendDescriptor(&d, witness); 1579 script_map->AppendDescriptor(&d, witness);
1577 } 1580 }
1578 1581
1579 { 1582 {
1580 CallbacksDescriptor d(*line_offset_symbol, *script_line_offset, attribs); 1583 CallbacksDescriptor d(*line_offset_string, *script_line_offset, attribs);
1581 script_map->AppendDescriptor(&d, witness); 1584 script_map->AppendDescriptor(&d, witness);
1582 } 1585 }
1583 1586
1584 { 1587 {
1585 CallbacksDescriptor d( 1588 CallbacksDescriptor d(
1586 *column_offset_symbol, *script_column_offset, attribs); 1589 *column_offset_string, *script_column_offset, attribs);
1587 script_map->AppendDescriptor(&d, witness); 1590 script_map->AppendDescriptor(&d, witness);
1588 } 1591 }
1589 1592
1590 { 1593 {
1591 CallbacksDescriptor d(*data_symbol, *script_data, attribs); 1594 CallbacksDescriptor d(*data_string, *script_data, attribs);
1592 script_map->AppendDescriptor(&d, witness); 1595 script_map->AppendDescriptor(&d, witness);
1593 } 1596 }
1594 1597
1595 { 1598 {
1596 CallbacksDescriptor d(*type_symbol, *script_type, attribs); 1599 CallbacksDescriptor d(*type_string, *script_type, attribs);
1597 script_map->AppendDescriptor(&d, witness); 1600 script_map->AppendDescriptor(&d, witness);
1598 } 1601 }
1599 1602
1600 { 1603 {
1601 CallbacksDescriptor d( 1604 CallbacksDescriptor d(
1602 *compilation_type_symbol, *script_compilation_type, attribs); 1605 *compilation_type_string, *script_compilation_type, attribs);
1603 script_map->AppendDescriptor(&d, witness); 1606 script_map->AppendDescriptor(&d, witness);
1604 } 1607 }
1605 1608
1606 { 1609 {
1607 CallbacksDescriptor d(*line_ends_symbol, *script_line_ends, attribs); 1610 CallbacksDescriptor d(*line_ends_string, *script_line_ends, attribs);
1608 script_map->AppendDescriptor(&d, witness); 1611 script_map->AppendDescriptor(&d, witness);
1609 } 1612 }
1610 1613
1611 { 1614 {
1612 CallbacksDescriptor d( 1615 CallbacksDescriptor d(
1613 *context_data_symbol, *script_context_data, attribs); 1616 *context_data_string, *script_context_data, attribs);
1614 script_map->AppendDescriptor(&d, witness); 1617 script_map->AppendDescriptor(&d, witness);
1615 } 1618 }
1616 1619
1617 { 1620 {
1618 CallbacksDescriptor d( 1621 CallbacksDescriptor d(
1619 *eval_from_script_symbol, *script_eval_from_script, attribs); 1622 *eval_from_script_string, *script_eval_from_script, attribs);
1620 script_map->AppendDescriptor(&d, witness); 1623 script_map->AppendDescriptor(&d, witness);
1621 } 1624 }
1622 1625
1623 { 1626 {
1624 CallbacksDescriptor d( 1627 CallbacksDescriptor d(
1625 *eval_from_script_position_symbol, 1628 *eval_from_script_position_string,
1626 *script_eval_from_script_position, 1629 *script_eval_from_script_position,
1627 attribs); 1630 attribs);
1628 script_map->AppendDescriptor(&d, witness); 1631 script_map->AppendDescriptor(&d, witness);
1629 } 1632 }
1630 1633
1631 { 1634 {
1632 CallbacksDescriptor d( 1635 CallbacksDescriptor d(
1633 *eval_from_function_name_symbol, 1636 *eval_from_function_name_string,
1634 *script_eval_from_function_name, 1637 *script_eval_from_function_name,
1635 attribs); 1638 attribs);
1636 script_map->AppendDescriptor(&d, witness); 1639 script_map->AppendDescriptor(&d, witness);
1637 } 1640 }
1638 1641
1639 // Allocate the empty script. 1642 // Allocate the empty script.
1640 Handle<Script> script = factory()->NewScript(factory()->empty_string()); 1643 Handle<Script> script = factory()->NewScript(factory()->empty_string());
1641 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); 1644 script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
1642 heap()->public_set_empty_script(*script); 1645 heap()->public_set_empty_script(*script);
1643 } 1646 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 DescriptorArray::WhitenessWitness witness(*array_descriptors); 1699 DescriptorArray::WhitenessWitness witness(*array_descriptors);
1697 1700
1698 Handle<Foreign> array_length(factory()->NewForeign( 1701 Handle<Foreign> array_length(factory()->NewForeign(
1699 &Accessors::ArrayLength)); 1702 &Accessors::ArrayLength));
1700 PropertyAttributes attribs = static_cast<PropertyAttributes>( 1703 PropertyAttributes attribs = static_cast<PropertyAttributes>(
1701 DONT_ENUM | DONT_DELETE); 1704 DONT_ENUM | DONT_DELETE);
1702 initial_map->set_instance_descriptors(*array_descriptors); 1705 initial_map->set_instance_descriptors(*array_descriptors);
1703 1706
1704 { // Add length. 1707 { // Add length.
1705 CallbacksDescriptor d( 1708 CallbacksDescriptor d(
1706 *factory()->length_symbol(), *array_length, attribs); 1709 *factory()->length_string(), *array_length, attribs);
1707 array_function->initial_map()->AppendDescriptor(&d, witness); 1710 array_function->initial_map()->AppendDescriptor(&d, witness);
1708 } 1711 }
1709 1712
1710 native_context()->set_internal_array_function(*array_function); 1713 native_context()->set_internal_array_function(*array_function);
1711 } 1714 }
1712 1715
1713 if (FLAG_disable_native_files) { 1716 if (FLAG_disable_native_files) {
1714 PrintF("Warning: Running without installed natives!\n"); 1717 PrintF("Warning: Running without installed natives!\n");
1715 return true; 1718 return true;
1716 } 1719 }
(...skipping 13 matching lines...) Expand all
1730 1733
1731 // Store the map for the string prototype after the natives has been compiled 1734 // Store the map for the string prototype after the natives has been compiled
1732 // and the String function has been set up. 1735 // and the String function has been set up.
1733 Handle<JSFunction> string_function(native_context()->string_function()); 1736 Handle<JSFunction> string_function(native_context()->string_function());
1734 ASSERT(JSObject::cast( 1737 ASSERT(JSObject::cast(
1735 string_function->initial_map()->prototype())->HasFastProperties()); 1738 string_function->initial_map()->prototype())->HasFastProperties());
1736 native_context()->set_string_function_prototype_map( 1739 native_context()->set_string_function_prototype_map(
1737 HeapObject::cast(string_function->initial_map()->prototype())->map()); 1740 HeapObject::cast(string_function->initial_map()->prototype())->map());
1738 1741
1739 // Install Function.prototype.call and apply. 1742 // Install Function.prototype.call and apply.
1740 { Handle<String> key = factory()->function_class_symbol(); 1743 { Handle<String> key = factory()->function_class_string();
1741 Handle<JSFunction> function = 1744 Handle<JSFunction> function =
1742 Handle<JSFunction>::cast(GetProperty(isolate()->global_object(), key)); 1745 Handle<JSFunction>::cast(GetProperty(isolate()->global_object(), key));
1743 Handle<JSObject> proto = 1746 Handle<JSObject> proto =
1744 Handle<JSObject>(JSObject::cast(function->instance_prototype())); 1747 Handle<JSObject>(JSObject::cast(function->instance_prototype()));
1745 1748
1746 // Install the call and the apply functions. 1749 // Install the call and the apply functions.
1747 Handle<JSFunction> call = 1750 Handle<JSFunction> call =
1748 InstallFunction(proto, "call", JS_OBJECT_TYPE, JSObject::kHeaderSize, 1751 InstallFunction(proto, "call", JS_OBJECT_TYPE, JSObject::kHeaderSize,
1749 Handle<JSObject>::null(), 1752 Handle<JSObject>::null(),
1750 Builtins::kFunctionCall, 1753 Builtins::kFunctionCall,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1793 // Update map with length accessor from Array and add "index" and "input". 1796 // Update map with length accessor from Array and add "index" and "input".
1794 Handle<DescriptorArray> reresult_descriptors = 1797 Handle<DescriptorArray> reresult_descriptors =
1795 factory()->NewDescriptorArray(0, 3); 1798 factory()->NewDescriptorArray(0, 3);
1796 DescriptorArray::WhitenessWitness witness(*reresult_descriptors); 1799 DescriptorArray::WhitenessWitness witness(*reresult_descriptors);
1797 initial_map->set_instance_descriptors(*reresult_descriptors); 1800 initial_map->set_instance_descriptors(*reresult_descriptors);
1798 1801
1799 { 1802 {
1800 JSFunction* array_function = native_context()->array_function(); 1803 JSFunction* array_function = native_context()->array_function();
1801 Handle<DescriptorArray> array_descriptors( 1804 Handle<DescriptorArray> array_descriptors(
1802 array_function->initial_map()->instance_descriptors()); 1805 array_function->initial_map()->instance_descriptors());
1803 String* length = heap()->length_symbol(); 1806 String* length = heap()->length_string();
1804 int old = array_descriptors->SearchWithCache( 1807 int old = array_descriptors->SearchWithCache(
1805 length, array_function->initial_map()); 1808 length, array_function->initial_map());
1806 ASSERT(old != DescriptorArray::kNotFound); 1809 ASSERT(old != DescriptorArray::kNotFound);
1807 CallbacksDescriptor desc(length, 1810 CallbacksDescriptor desc(length,
1808 array_descriptors->GetValue(old), 1811 array_descriptors->GetValue(old),
1809 array_descriptors->GetDetails(old).attributes()); 1812 array_descriptors->GetDetails(old).attributes());
1810 initial_map->AppendDescriptor(&desc, witness); 1813 initial_map->AppendDescriptor(&desc, witness);
1811 } 1814 }
1812 { 1815 {
1813 FieldDescriptor index_field(heap()->index_symbol(), 1816 FieldDescriptor index_field(heap()->index_string(),
1814 JSRegExpResult::kIndexIndex, 1817 JSRegExpResult::kIndexIndex,
1815 NONE); 1818 NONE);
1816 initial_map->AppendDescriptor(&index_field, witness); 1819 initial_map->AppendDescriptor(&index_field, witness);
1817 } 1820 }
1818 1821
1819 { 1822 {
1820 FieldDescriptor input_field(heap()->input_symbol(), 1823 FieldDescriptor input_field(heap()->input_string(),
1821 JSRegExpResult::kInputIndex, 1824 JSRegExpResult::kInputIndex,
1822 NONE); 1825 NONE);
1823 initial_map->AppendDescriptor(&input_field, witness); 1826 initial_map->AppendDescriptor(&input_field, witness);
1824 } 1827 }
1825 1828
1826 initial_map->set_inobject_properties(2); 1829 initial_map->set_inobject_properties(2);
1827 initial_map->set_pre_allocated_property_fields(2); 1830 initial_map->set_pre_allocated_property_fields(2);
1828 initial_map->set_unused_property_fields(0); 1831 initial_map->set_unused_property_fields(0);
1829 1832
1830 native_context()->set_regexp_result_map(*initial_map); 1833 native_context()->set_regexp_result_map(*initial_map);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1866 1869
1867 1870
1868 static Handle<JSObject> ResolveBuiltinIdHolder( 1871 static Handle<JSObject> ResolveBuiltinIdHolder(
1869 Handle<Context> native_context, 1872 Handle<Context> native_context,
1870 const char* holder_expr) { 1873 const char* holder_expr) {
1871 Factory* factory = native_context->GetIsolate()->factory(); 1874 Factory* factory = native_context->GetIsolate()->factory();
1872 Handle<GlobalObject> global(native_context->global_object()); 1875 Handle<GlobalObject> global(native_context->global_object());
1873 const char* period_pos = strchr(holder_expr, '.'); 1876 const char* period_pos = strchr(holder_expr, '.');
1874 if (period_pos == NULL) { 1877 if (period_pos == NULL) {
1875 return Handle<JSObject>::cast( 1878 return Handle<JSObject>::cast(
1876 GetProperty(global, factory->LookupUtf8Symbol(holder_expr))); 1879 GetProperty(global, factory->InternalizeUtf8String(holder_expr)));
1877 } 1880 }
1878 ASSERT_EQ(".prototype", period_pos); 1881 ASSERT_EQ(".prototype", period_pos);
1879 Vector<const char> property(holder_expr, 1882 Vector<const char> property(holder_expr,
1880 static_cast<int>(period_pos - holder_expr)); 1883 static_cast<int>(period_pos - holder_expr));
1881 Handle<JSFunction> function = Handle<JSFunction>::cast( 1884 Handle<JSFunction> function = Handle<JSFunction>::cast(
1882 GetProperty(global, factory->LookupUtf8Symbol(property))); 1885 GetProperty(global, factory->InternalizeUtf8String(property)));
1883 return Handle<JSObject>(JSObject::cast(function->prototype())); 1886 return Handle<JSObject>(JSObject::cast(function->prototype()));
1884 } 1887 }
1885 1888
1886 1889
1887 static void InstallBuiltinFunctionId(Handle<JSObject> holder, 1890 static void InstallBuiltinFunctionId(Handle<JSObject> holder,
1888 const char* function_name, 1891 const char* function_name,
1889 BuiltinFunctionId id) { 1892 BuiltinFunctionId id) {
1890 Factory* factory = holder->GetIsolate()->factory(); 1893 Factory* factory = holder->GetIsolate()->factory();
1891 Handle<String> name = factory->LookupUtf8Symbol(function_name); 1894 Handle<String> name = factory->InternalizeUtf8String(function_name);
1892 Object* function_object = holder->GetProperty(*name)->ToObjectUnchecked(); 1895 Object* function_object = holder->GetProperty(*name)->ToObjectUnchecked();
1893 Handle<JSFunction> function(JSFunction::cast(function_object)); 1896 Handle<JSFunction> function(JSFunction::cast(function_object));
1894 function->shared()->set_function_data(Smi::FromInt(id)); 1897 function->shared()->set_function_data(Smi::FromInt(id));
1895 } 1898 }
1896 1899
1897 1900
1898 void Genesis::InstallBuiltinFunctionIds() { 1901 void Genesis::InstallBuiltinFunctionIds() {
1899 HandleScope scope; 1902 HandleScope scope;
1900 #define INSTALL_BUILTIN_ID(holder_expr, fun_name, name) \ 1903 #define INSTALL_BUILTIN_ID(holder_expr, fun_name, name) \
1901 { \ 1904 { \
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1972 1975
1973 1976
1974 void Genesis::InstallSpecialObjects(Handle<Context> native_context) { 1977 void Genesis::InstallSpecialObjects(Handle<Context> native_context) {
1975 Isolate* isolate = native_context->GetIsolate(); 1978 Isolate* isolate = native_context->GetIsolate();
1976 Factory* factory = isolate->factory(); 1979 Factory* factory = isolate->factory();
1977 HandleScope scope; 1980 HandleScope scope;
1978 Handle<JSGlobalObject> global(JSGlobalObject::cast( 1981 Handle<JSGlobalObject> global(JSGlobalObject::cast(
1979 native_context->global_object())); 1982 native_context->global_object()));
1980 // Expose the natives in global if a name for it is specified. 1983 // Expose the natives in global if a name for it is specified.
1981 if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) { 1984 if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) {
1982 Handle<String> natives = factory->LookupUtf8Symbol(FLAG_expose_natives_as); 1985 Handle<String> natives =
1986 factory->InternalizeUtf8String(FLAG_expose_natives_as);
1983 CHECK_NOT_EMPTY_HANDLE(isolate, 1987 CHECK_NOT_EMPTY_HANDLE(isolate,
1984 JSObject::SetLocalPropertyIgnoreAttributes( 1988 JSObject::SetLocalPropertyIgnoreAttributes(
1985 global, natives, 1989 global, natives,
1986 Handle<JSObject>(global->builtins()), 1990 Handle<JSObject>(global->builtins()),
1987 DONT_ENUM)); 1991 DONT_ENUM));
1988 } 1992 }
1989 1993
1990 Handle<Object> Error = GetProperty(global, "Error"); 1994 Handle<Object> Error = GetProperty(global, "Error");
1991 if (Error->IsJSObject()) { 1995 if (Error->IsJSObject()) {
1992 Handle<String> name = 1996 Handle<String> name = factory->InternalizeOneByteString(
1993 factory->LookupOneByteSymbol(STATIC_ASCII_VECTOR("stackTraceLimit")); 1997 STATIC_ASCII_VECTOR("stackTraceLimit"));
1994 Handle<Smi> stack_trace_limit(Smi::FromInt(FLAG_stack_trace_limit)); 1998 Handle<Smi> stack_trace_limit(Smi::FromInt(FLAG_stack_trace_limit));
1995 CHECK_NOT_EMPTY_HANDLE(isolate, 1999 CHECK_NOT_EMPTY_HANDLE(isolate,
1996 JSObject::SetLocalPropertyIgnoreAttributes( 2000 JSObject::SetLocalPropertyIgnoreAttributes(
1997 Handle<JSObject>::cast(Error), name, 2001 Handle<JSObject>::cast(Error), name,
1998 stack_trace_limit, NONE)); 2002 stack_trace_limit, NONE));
1999 } 2003 }
2000 2004
2001 #ifdef ENABLE_DEBUGGER_SUPPORT 2005 #ifdef ENABLE_DEBUGGER_SUPPORT
2002 // Expose the debug global object in global if a name for it is specified. 2006 // Expose the debug global object in global if a name for it is specified.
2003 if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) { 2007 if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) {
2004 Debug* debug = Isolate::Current()->debug(); 2008 Debug* debug = Isolate::Current()->debug();
2005 // If loading fails we just bail out without installing the 2009 // If loading fails we just bail out without installing the
2006 // debugger but without tanking the whole context. 2010 // debugger but without tanking the whole context.
2007 if (!debug->Load()) return; 2011 if (!debug->Load()) return;
2008 // Set the security token for the debugger context to the same as 2012 // Set the security token for the debugger context to the same as
2009 // the shell native context to allow calling between these (otherwise 2013 // the shell native context to allow calling between these (otherwise
2010 // exposing debug global object doesn't make much sense). 2014 // exposing debug global object doesn't make much sense).
2011 debug->debug_context()->set_security_token( 2015 debug->debug_context()->set_security_token(
2012 native_context->security_token()); 2016 native_context->security_token());
2013 2017
2014 Handle<String> debug_string = 2018 Handle<String> debug_string =
2015 factory->LookupUtf8Symbol(FLAG_expose_debug_as); 2019 factory->InternalizeUtf8String(FLAG_expose_debug_as);
2016 Handle<Object> global_proxy(debug->debug_context()->global_proxy()); 2020 Handle<Object> global_proxy(debug->debug_context()->global_proxy());
2017 CHECK_NOT_EMPTY_HANDLE(isolate, 2021 CHECK_NOT_EMPTY_HANDLE(isolate,
2018 JSObject::SetLocalPropertyIgnoreAttributes( 2022 JSObject::SetLocalPropertyIgnoreAttributes(
2019 global, debug_string, global_proxy, DONT_ENUM)); 2023 global, debug_string, global_proxy, DONT_ENUM));
2020 } 2024 }
2021 #endif 2025 #endif
2022 } 2026 }
2023 2027
2024 static uint32_t Hash(RegisteredExtension* extension) { 2028 static uint32_t Hash(RegisteredExtension* extension) {
2025 return v8::internal::ComputePointerHash(extension); 2029 return v8::internal::ComputePointerHash(extension);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
2149 isolate->NotifyExtensionInstalled(); 2153 isolate->NotifyExtensionInstalled();
2150 return result; 2154 return result;
2151 } 2155 }
2152 2156
2153 2157
2154 bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) { 2158 bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) {
2155 HandleScope scope; 2159 HandleScope scope;
2156 Factory* factory = builtins->GetIsolate()->factory(); 2160 Factory* factory = builtins->GetIsolate()->factory();
2157 for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) { 2161 for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) {
2158 Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i); 2162 Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i);
2159 Handle<String> name = factory->LookupUtf8Symbol(Builtins::GetName(id)); 2163 Handle<String> name = factory->InternalizeUtf8String(Builtins::GetName(id));
2160 Object* function_object = builtins->GetPropertyNoExceptionThrown(*name); 2164 Object* function_object = builtins->GetPropertyNoExceptionThrown(*name);
2161 Handle<JSFunction> function 2165 Handle<JSFunction> function
2162 = Handle<JSFunction>(JSFunction::cast(function_object)); 2166 = Handle<JSFunction>(JSFunction::cast(function_object));
2163 builtins->set_javascript_builtin(id, *function); 2167 builtins->set_javascript_builtin(id, *function);
2164 if (!JSFunction::CompileLazy(function, CLEAR_EXCEPTION)) { 2168 if (!JSFunction::CompileLazy(function, CLEAR_EXCEPTION)) {
2165 return false; 2169 return false;
2166 } 2170 }
2167 builtins->set_javascript_builtin_code(id, function->shared()->code()); 2171 builtins->set_javascript_builtin_code(id, function->shared()->code());
2168 } 2172 }
2169 return true; 2173 return true;
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
2429 return from + sizeof(NestingCounterType); 2433 return from + sizeof(NestingCounterType);
2430 } 2434 }
2431 2435
2432 2436
2433 // Called when the top-level V8 mutex is destroyed. 2437 // Called when the top-level V8 mutex is destroyed.
2434 void Bootstrapper::FreeThreadResources() { 2438 void Bootstrapper::FreeThreadResources() {
2435 ASSERT(!IsActive()); 2439 ASSERT(!IsActive());
2436 } 2440 }
2437 2441
2438 } } // namespace v8::internal 2442 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.cc ('k') | src/code-stubs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698