| OLD | NEW | 
|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 257 | 257 | 
| 258   Handle<Map> CreateFunctionMap(PrototypePropertyMode prototype_mode); | 258   Handle<Map> CreateFunctionMap(PrototypePropertyMode prototype_mode); | 
| 259 | 259 | 
| 260   Handle<DescriptorArray> ComputeFunctionInstanceDescriptor( | 260   Handle<DescriptorArray> ComputeFunctionInstanceDescriptor( | 
| 261       PrototypePropertyMode prototypeMode); | 261       PrototypePropertyMode prototypeMode); | 
| 262   void MakeFunctionInstancePrototypeWritable(); | 262   void MakeFunctionInstancePrototypeWritable(); | 
| 263 | 263 | 
| 264   Handle<Map> CreateStrictModeFunctionMap( | 264   Handle<Map> CreateStrictModeFunctionMap( | 
| 265       PrototypePropertyMode prototype_mode, | 265       PrototypePropertyMode prototype_mode, | 
| 266       Handle<JSFunction> empty_function, | 266       Handle<JSFunction> empty_function, | 
| 267       Handle<FixedArray> arguments_callbacks, | 267       Handle<AccessorPair> arguments_callbacks, | 
| 268       Handle<FixedArray> caller_callbacks); | 268       Handle<AccessorPair> caller_callbacks); | 
| 269 | 269 | 
| 270   Handle<DescriptorArray> ComputeStrictFunctionInstanceDescriptor( | 270   Handle<DescriptorArray> ComputeStrictFunctionInstanceDescriptor( | 
| 271       PrototypePropertyMode propertyMode, | 271       PrototypePropertyMode propertyMode, | 
| 272       Handle<FixedArray> arguments, | 272       Handle<AccessorPair> arguments, | 
| 273       Handle<FixedArray> caller); | 273       Handle<AccessorPair> caller); | 
| 274 | 274 | 
| 275   static bool CompileBuiltin(Isolate* isolate, int index); | 275   static bool CompileBuiltin(Isolate* isolate, int index); | 
| 276   static bool CompileExperimentalBuiltin(Isolate* isolate, int index); | 276   static bool CompileExperimentalBuiltin(Isolate* isolate, int index); | 
| 277   static bool CompileNative(Vector<const char> name, Handle<String> source); | 277   static bool CompileNative(Vector<const char> name, Handle<String> source); | 
| 278   static bool CompileScriptCached(Vector<const char> name, | 278   static bool CompileScriptCached(Vector<const char> name, | 
| 279                                   Handle<String> source, | 279                                   Handle<String> source, | 
| 280                                   SourceCodeCache* cache, | 280                                   SourceCodeCache* cache, | 
| 281                                   v8::Extension* extension, | 281                                   v8::Extension* extension, | 
| 282                                   Handle<Context> top_context, | 282                                   Handle<Context> top_context, | 
| 283                                   bool use_runtime_context); | 283                                   bool use_runtime_context); | 
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 371                                       prototype, | 371                                       prototype, | 
| 372                                       call_code, | 372                                       call_code, | 
| 373                                       is_ecma_native); | 373                                       is_ecma_native); | 
| 374   PropertyAttributes attributes; | 374   PropertyAttributes attributes; | 
| 375   if (target->IsJSBuiltinsObject()) { | 375   if (target->IsJSBuiltinsObject()) { | 
| 376     attributes = | 376     attributes = | 
| 377         static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 377         static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 
| 378   } else { | 378   } else { | 
| 379     attributes = DONT_ENUM; | 379     attributes = DONT_ENUM; | 
| 380   } | 380   } | 
| 381   SetLocalPropertyNoThrow(target, symbol, function, attributes); | 381   CHECK_NOT_EMPTY_HANDLE(isolate, | 
|  | 382                          JSObject::SetLocalPropertyIgnoreAttributes( | 
|  | 383                              target, symbol, function, attributes)); | 
| 382   if (is_ecma_native) { | 384   if (is_ecma_native) { | 
| 383     function->shared()->set_instance_class_name(*symbol); | 385     function->shared()->set_instance_class_name(*symbol); | 
| 384   } | 386   } | 
| 385   function->shared()->set_native(true); | 387   function->shared()->set_native(true); | 
| 386   return function; | 388   return function; | 
| 387 } | 389 } | 
| 388 | 390 | 
| 389 | 391 | 
| 390 Handle<DescriptorArray> Genesis::ComputeFunctionInstanceDescriptor( | 392 Handle<DescriptorArray> Genesis::ComputeFunctionInstanceDescriptor( | 
| 391     PrototypePropertyMode prototypeMode) { | 393     PrototypePropertyMode prototypeMode) { | 
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 531   empty_fm->set_instance_descriptors( | 533   empty_fm->set_instance_descriptors( | 
| 532       function_without_prototype_map->instance_descriptors()); | 534       function_without_prototype_map->instance_descriptors()); | 
| 533   empty_fm->set_prototype(global_context()->object_function()->prototype()); | 535   empty_fm->set_prototype(global_context()->object_function()->prototype()); | 
| 534   empty_function->set_map(*empty_fm); | 536   empty_function->set_map(*empty_fm); | 
| 535   return empty_function; | 537   return empty_function; | 
| 536 } | 538 } | 
| 537 | 539 | 
| 538 | 540 | 
| 539 Handle<DescriptorArray> Genesis::ComputeStrictFunctionInstanceDescriptor( | 541 Handle<DescriptorArray> Genesis::ComputeStrictFunctionInstanceDescriptor( | 
| 540     PrototypePropertyMode prototypeMode, | 542     PrototypePropertyMode prototypeMode, | 
| 541     Handle<FixedArray> arguments, | 543     Handle<AccessorPair> arguments, | 
| 542     Handle<FixedArray> caller) { | 544     Handle<AccessorPair> caller) { | 
| 543   Handle<DescriptorArray> descriptors = | 545   Handle<DescriptorArray> descriptors = | 
| 544       factory()->NewDescriptorArray(prototypeMode == DONT_ADD_PROTOTYPE | 546       factory()->NewDescriptorArray(prototypeMode == DONT_ADD_PROTOTYPE | 
| 545                                     ? 4 | 547                                     ? 4 | 
| 546                                     : 5); | 548                                     : 5); | 
| 547   PropertyAttributes attributes = static_cast<PropertyAttributes>( | 549   PropertyAttributes attributes = static_cast<PropertyAttributes>( | 
| 548       DONT_ENUM | DONT_DELETE); | 550       DONT_ENUM | DONT_DELETE); | 
| 549 | 551 | 
| 550   DescriptorArray::WhitenessWitness witness(*descriptors); | 552   DescriptorArray::WhitenessWitness witness(*descriptors); | 
| 551 | 553 | 
| 552   {  // length | 554   {  // length | 
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 593     throw_type_error_function = | 595     throw_type_error_function = | 
| 594       factory()->NewFunctionWithoutPrototype(name, CLASSIC_MODE); | 596       factory()->NewFunctionWithoutPrototype(name, CLASSIC_MODE); | 
| 595     Handle<Code> code(isolate()->builtins()->builtin( | 597     Handle<Code> code(isolate()->builtins()->builtin( | 
| 596         Builtins::kStrictModePoisonPill)); | 598         Builtins::kStrictModePoisonPill)); | 
| 597     throw_type_error_function->set_map( | 599     throw_type_error_function->set_map( | 
| 598         global_context()->function_map()); | 600         global_context()->function_map()); | 
| 599     throw_type_error_function->set_code(*code); | 601     throw_type_error_function->set_code(*code); | 
| 600     throw_type_error_function->shared()->set_code(*code); | 602     throw_type_error_function->shared()->set_code(*code); | 
| 601     throw_type_error_function->shared()->DontAdaptArguments(); | 603     throw_type_error_function->shared()->DontAdaptArguments(); | 
| 602 | 604 | 
| 603     PreventExtensions(throw_type_error_function); | 605     JSObject::PreventExtensions(throw_type_error_function); | 
| 604   } | 606   } | 
| 605   return throw_type_error_function; | 607   return throw_type_error_function; | 
| 606 } | 608 } | 
| 607 | 609 | 
| 608 | 610 | 
| 609 Handle<Map> Genesis::CreateStrictModeFunctionMap( | 611 Handle<Map> Genesis::CreateStrictModeFunctionMap( | 
| 610     PrototypePropertyMode prototype_mode, | 612     PrototypePropertyMode prototype_mode, | 
| 611     Handle<JSFunction> empty_function, | 613     Handle<JSFunction> empty_function, | 
| 612     Handle<FixedArray> arguments_callbacks, | 614     Handle<AccessorPair> arguments_callbacks, | 
| 613     Handle<FixedArray> caller_callbacks) { | 615     Handle<AccessorPair> caller_callbacks) { | 
| 614   Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); | 616   Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); | 
| 615   Handle<DescriptorArray> descriptors = | 617   Handle<DescriptorArray> descriptors = | 
| 616       ComputeStrictFunctionInstanceDescriptor(prototype_mode, | 618       ComputeStrictFunctionInstanceDescriptor(prototype_mode, | 
| 617                                               arguments_callbacks, | 619                                               arguments_callbacks, | 
| 618                                               caller_callbacks); | 620                                               caller_callbacks); | 
| 619   map->set_instance_descriptors(*descriptors); | 621   map->set_instance_descriptors(*descriptors); | 
| 620   map->set_function_with_prototype(prototype_mode != DONT_ADD_PROTOTYPE); | 622   map->set_function_with_prototype(prototype_mode != DONT_ADD_PROTOTYPE); | 
| 621   map->set_prototype(*empty_function); | 623   map->set_prototype(*empty_function); | 
| 622   return map; | 624   return map; | 
| 623 } | 625 } | 
| 624 | 626 | 
| 625 | 627 | 
| 626 void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) { | 628 void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) { | 
| 627   // Create the callbacks arrays for ThrowTypeError functions. | 629   // Create the callbacks arrays for ThrowTypeError functions. | 
| 628   // The get/set callacks are filled in after the maps are created below. | 630   // The get/set callacks are filled in after the maps are created below. | 
| 629   Factory* factory = empty->GetIsolate()->factory(); | 631   Factory* factory = empty->GetIsolate()->factory(); | 
| 630   Handle<FixedArray> arguments = factory->NewFixedArray(2, TENURED); | 632   Handle<AccessorPair> arguments(factory->NewAccessorPair()); | 
| 631   Handle<FixedArray> caller = factory->NewFixedArray(2, TENURED); | 633   Handle<AccessorPair> caller(factory->NewAccessorPair()); | 
| 632 | 634 | 
| 633   // Allocate map for the strict mode function instances. | 635   // Allocate map for the strict mode function instances. | 
| 634   Handle<Map> strict_mode_function_instance_map = | 636   Handle<Map> strict_mode_function_instance_map = | 
| 635       CreateStrictModeFunctionMap( | 637       CreateStrictModeFunctionMap( | 
| 636           ADD_WRITEABLE_PROTOTYPE, empty, arguments, caller); | 638           ADD_WRITEABLE_PROTOTYPE, empty, arguments, caller); | 
| 637   global_context()->set_strict_mode_function_instance_map( | 639   global_context()->set_strict_mode_function_instance_map( | 
| 638       *strict_mode_function_instance_map); | 640       *strict_mode_function_instance_map); | 
| 639 | 641 | 
| 640   // Allocate map for the prototype-less strict mode instances. | 642   // Allocate map for the prototype-less strict mode instances. | 
| 641   Handle<Map> strict_mode_function_without_prototype_map = | 643   Handle<Map> strict_mode_function_without_prototype_map = | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
| 656   // The final map for the strict mode functions. Writeable prototype. | 658   // The final map for the strict mode functions. Writeable prototype. | 
| 657   // This map is installed in MakeFunctionInstancePrototypeWritable. | 659   // This map is installed in MakeFunctionInstancePrototypeWritable. | 
| 658   strict_mode_function_instance_map_writable_prototype_ = | 660   strict_mode_function_instance_map_writable_prototype_ = | 
| 659       CreateStrictModeFunctionMap( | 661       CreateStrictModeFunctionMap( | 
| 660           ADD_WRITEABLE_PROTOTYPE, empty, arguments, caller); | 662           ADD_WRITEABLE_PROTOTYPE, empty, arguments, caller); | 
| 661 | 663 | 
| 662   // Create the ThrowTypeError function instance. | 664   // Create the ThrowTypeError function instance. | 
| 663   Handle<JSFunction> throw_function = | 665   Handle<JSFunction> throw_function = | 
| 664       GetThrowTypeErrorFunction(); | 666       GetThrowTypeErrorFunction(); | 
| 665 | 667 | 
| 666   // Complete the callback fixed arrays. | 668   // Complete the callbacks. | 
| 667   arguments->set(0, *throw_function); | 669   arguments->set_getter(*throw_function); | 
| 668   arguments->set(1, *throw_function); | 670   arguments->set_setter(*throw_function); | 
| 669   caller->set(0, *throw_function); | 671   caller->set_getter(*throw_function); | 
| 670   caller->set(1, *throw_function); | 672   caller->set_setter(*throw_function); | 
| 671 } | 673 } | 
| 672 | 674 | 
| 673 | 675 | 
| 674 static void AddToWeakGlobalContextList(Context* context) { | 676 static void AddToWeakGlobalContextList(Context* context) { | 
| 675   ASSERT(context->IsGlobalContext()); | 677   ASSERT(context->IsGlobalContext()); | 
| 676   Heap* heap = context->GetIsolate()->heap(); | 678   Heap* heap = context->GetIsolate()->heap(); | 
| 677 #ifdef DEBUG | 679 #ifdef DEBUG | 
| 678   { // NOLINT | 680   { // NOLINT | 
| 679     ASSERT(context->get(Context::NEXT_CONTEXT_LINK)->IsUndefined()); | 681     ASSERT(context->get(Context::NEXT_CONTEXT_LINK)->IsUndefined()); | 
| 680     // Check that context is not in the list yet. | 682     // Check that context is not in the list yet. | 
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 746     Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin( | 748     Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin( | 
| 747         Builtins::kIllegal)); | 749         Builtins::kIllegal)); | 
| 748     js_global_function = | 750     js_global_function = | 
| 749         factory()->NewFunction(name, JS_GLOBAL_OBJECT_TYPE, | 751         factory()->NewFunction(name, JS_GLOBAL_OBJECT_TYPE, | 
| 750                                JSGlobalObject::kSize, code, true); | 752                                JSGlobalObject::kSize, code, true); | 
| 751     // Change the constructor property of the prototype of the | 753     // Change the constructor property of the prototype of the | 
| 752     // hidden global function to refer to the Object function. | 754     // hidden global function to refer to the Object function. | 
| 753     Handle<JSObject> prototype = | 755     Handle<JSObject> prototype = | 
| 754         Handle<JSObject>( | 756         Handle<JSObject>( | 
| 755             JSObject::cast(js_global_function->instance_prototype())); | 757             JSObject::cast(js_global_function->instance_prototype())); | 
| 756     SetLocalPropertyNoThrow( | 758     CHECK_NOT_EMPTY_HANDLE(isolate(), | 
| 757         prototype, | 759                            JSObject::SetLocalPropertyIgnoreAttributes( | 
| 758         factory()->constructor_symbol(), | 760                                prototype, factory()->constructor_symbol(), | 
| 759         isolate()->object_function(), | 761                                isolate()->object_function(), NONE)); | 
| 760         NONE); |  | 
| 761   } else { | 762   } else { | 
| 762     Handle<FunctionTemplateInfo> js_global_constructor( | 763     Handle<FunctionTemplateInfo> js_global_constructor( | 
| 763         FunctionTemplateInfo::cast(js_global_template->constructor())); | 764         FunctionTemplateInfo::cast(js_global_template->constructor())); | 
| 764     js_global_function = | 765     js_global_function = | 
| 765         factory()->CreateApiFunction(js_global_constructor, | 766         factory()->CreateApiFunction(js_global_constructor, | 
| 766                                      factory()->InnerGlobalObject); | 767                                      factory()->InnerGlobalObject); | 
| 767   } | 768   } | 
| 768 | 769 | 
| 769   js_global_function->initial_map()->set_is_hidden_prototype(); | 770   js_global_function->initial_map()->set_is_hidden_prototype(); | 
| 770   Handle<GlobalObject> inner_global = | 771   Handle<GlobalObject> inner_global = | 
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 827   Handle<JSBuiltinsObject> builtins_global(global_context_->builtins()); | 828   Handle<JSBuiltinsObject> builtins_global(global_context_->builtins()); | 
| 828   global_context_->set_extension(*inner_global); | 829   global_context_->set_extension(*inner_global); | 
| 829   global_context_->set_global(*inner_global); | 830   global_context_->set_global(*inner_global); | 
| 830   global_context_->set_security_token(*inner_global); | 831   global_context_->set_security_token(*inner_global); | 
| 831   static const PropertyAttributes attributes = | 832   static const PropertyAttributes attributes = | 
| 832       static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); | 833       static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); | 
| 833   ForceSetProperty(builtins_global, | 834   ForceSetProperty(builtins_global, | 
| 834                    factory()->LookupAsciiSymbol("global"), | 835                    factory()->LookupAsciiSymbol("global"), | 
| 835                    inner_global, | 836                    inner_global, | 
| 836                    attributes); | 837                    attributes); | 
| 837   // Setup the reference from the global object to the builtins object. | 838   // Set up the reference from the global object to the builtins object. | 
| 838   JSGlobalObject::cast(*inner_global)->set_builtins(*builtins_global); | 839   JSGlobalObject::cast(*inner_global)->set_builtins(*builtins_global); | 
| 839   TransferNamedProperties(inner_global_from_snapshot, inner_global); | 840   TransferNamedProperties(inner_global_from_snapshot, inner_global); | 
| 840   TransferIndexedProperties(inner_global_from_snapshot, inner_global); | 841   TransferIndexedProperties(inner_global_from_snapshot, inner_global); | 
| 841 } | 842 } | 
| 842 | 843 | 
| 843 | 844 | 
| 844 // This is only called if we are not using snapshots.  The equivalent | 845 // This is only called if we are not using snapshots.  The equivalent | 
| 845 // work in the snapshot case is done in HookUpInnerGlobal. | 846 // work in the snapshot case is done in HookUpInnerGlobal. | 
| 846 void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, | 847 void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, | 
| 847                                Handle<JSFunction> empty_function) { | 848                                Handle<JSFunction> empty_function) { | 
| 848   // --- G l o b a l   C o n t e x t --- | 849   // --- G l o b a l   C o n t e x t --- | 
| 849   // Use the empty function as closure (no scope info). | 850   // Use the empty function as closure (no scope info). | 
| 850   global_context()->set_closure(*empty_function); | 851   global_context()->set_closure(*empty_function); | 
| 851   global_context()->set_previous(NULL); | 852   global_context()->set_previous(NULL); | 
| 852   // Set extension and global object. | 853   // Set extension and global object. | 
| 853   global_context()->set_extension(*inner_global); | 854   global_context()->set_extension(*inner_global); | 
| 854   global_context()->set_global(*inner_global); | 855   global_context()->set_global(*inner_global); | 
| 855   // Security setup: Set the security token of the global object to | 856   // Security setup: Set the security token of the global object to | 
| 856   // its the inner global. This makes the security check between two | 857   // its the inner global. This makes the security check between two | 
| 857   // different contexts fail by default even in case of global | 858   // different contexts fail by default even in case of global | 
| 858   // object reinitialization. | 859   // object reinitialization. | 
| 859   global_context()->set_security_token(*inner_global); | 860   global_context()->set_security_token(*inner_global); | 
| 860 | 861 | 
| 861   Isolate* isolate = inner_global->GetIsolate(); | 862   Isolate* isolate = inner_global->GetIsolate(); | 
| 862   Factory* factory = isolate->factory(); | 863   Factory* factory = isolate->factory(); | 
| 863   Heap* heap = isolate->heap(); | 864   Heap* heap = isolate->heap(); | 
| 864 | 865 | 
| 865   Handle<String> object_name = Handle<String>(heap->Object_symbol()); | 866   Handle<String> object_name = Handle<String>(heap->Object_symbol()); | 
| 866   SetLocalPropertyNoThrow(inner_global, object_name, | 867   CHECK_NOT_EMPTY_HANDLE(isolate, | 
| 867                           isolate->object_function(), DONT_ENUM); | 868                          JSObject::SetLocalPropertyIgnoreAttributes( | 
|  | 869                              inner_global, object_name, | 
|  | 870                              isolate->object_function(), DONT_ENUM)); | 
| 868 | 871 | 
| 869   Handle<JSObject> global = Handle<JSObject>(global_context()->global()); | 872   Handle<JSObject> global = Handle<JSObject>(global_context()->global()); | 
| 870 | 873 | 
| 871   // Install global Function object | 874   // Install global Function object | 
| 872   InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, | 875   InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, | 
| 873                   empty_function, Builtins::kIllegal, true);  // ECMA native. | 876                   empty_function, Builtins::kIllegal, true);  // ECMA native. | 
| 874 | 877 | 
| 875   {  // --- A r r a y --- | 878   {  // --- A r r a y --- | 
| 876     Handle<JSFunction> array_function = | 879     Handle<JSFunction> array_function = | 
| 877         InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, | 880         InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, | 
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1039                                  Smi::FromInt(0), | 1042                                  Smi::FromInt(0), | 
| 1040                                  SKIP_WRITE_BARRIER);  // It's a Smi. | 1043                                  SKIP_WRITE_BARRIER);  // It's a Smi. | 
| 1041     initial_map->set_prototype(*proto); | 1044     initial_map->set_prototype(*proto); | 
| 1042     factory->SetRegExpIrregexpData(Handle<JSRegExp>::cast(proto), | 1045     factory->SetRegExpIrregexpData(Handle<JSRegExp>::cast(proto), | 
| 1043                                    JSRegExp::IRREGEXP, factory->empty_string(), | 1046                                    JSRegExp::IRREGEXP, factory->empty_string(), | 
| 1044                                    JSRegExp::Flags(0), 0); | 1047                                    JSRegExp::Flags(0), 0); | 
| 1045   } | 1048   } | 
| 1046 | 1049 | 
| 1047   {  // -- J S O N | 1050   {  // -- J S O N | 
| 1048     Handle<String> name = factory->NewStringFromAscii(CStrVector("JSON")); | 1051     Handle<String> name = factory->NewStringFromAscii(CStrVector("JSON")); | 
| 1049     Handle<JSFunction> cons = factory->NewFunction( | 1052     Handle<JSFunction> cons = factory->NewFunction(name, | 
| 1050         name, | 1053                                                    factory->the_hole_value()); | 
| 1051         factory->the_hole_value()); |  | 
| 1052     cons->SetInstancePrototype(global_context()->initial_object_prototype()); | 1054     cons->SetInstancePrototype(global_context()->initial_object_prototype()); | 
| 1053     cons->SetInstanceClassName(*name); | 1055     cons->SetInstanceClassName(*name); | 
| 1054     Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED); | 1056     Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED); | 
| 1055     ASSERT(json_object->IsJSObject()); | 1057     ASSERT(json_object->IsJSObject()); | 
| 1056     SetLocalPropertyNoThrow(global, name, json_object, DONT_ENUM); | 1058     CHECK_NOT_EMPTY_HANDLE(isolate, | 
|  | 1059                            JSObject::SetLocalPropertyIgnoreAttributes( | 
|  | 1060                                  global, name, json_object, DONT_ENUM)); | 
| 1057     global_context()->set_json_object(*json_object); | 1061     global_context()->set_json_object(*json_object); | 
| 1058   } | 1062   } | 
| 1059 | 1063 | 
| 1060   {  // --- arguments_boilerplate_ | 1064   {  // --- arguments_boilerplate_ | 
| 1061     // Make sure we can recognize argument objects at runtime. | 1065     // Make sure we can recognize argument objects at runtime. | 
| 1062     // This is done by introducing an anonymous function with | 1066     // This is done by introducing an anonymous function with | 
| 1063     // class_name equals 'Arguments'. | 1067     // class_name equals 'Arguments'. | 
| 1064     Handle<String> symbol = factory->LookupAsciiSymbol("Arguments"); | 1068     Handle<String> symbol = factory->LookupAsciiSymbol("Arguments"); | 
| 1065     Handle<Code> code = Handle<Code>( | 1069     Handle<Code> code = Handle<Code>( | 
| 1066         isolate->builtins()->builtin(Builtins::kIllegal)); | 1070         isolate->builtins()->builtin(Builtins::kIllegal)); | 
| 1067     Handle<JSObject> prototype = | 1071     Handle<JSObject> prototype = | 
| 1068         Handle<JSObject>( | 1072         Handle<JSObject>( | 
| 1069             JSObject::cast(global_context()->object_function()->prototype())); | 1073             JSObject::cast(global_context()->object_function()->prototype())); | 
| 1070 | 1074 | 
| 1071     Handle<JSFunction> function = | 1075     Handle<JSFunction> function = | 
| 1072         factory->NewFunctionWithPrototype(symbol, | 1076         factory->NewFunctionWithPrototype(symbol, | 
| 1073                                           JS_OBJECT_TYPE, | 1077                                           JS_OBJECT_TYPE, | 
| 1074                                           JSObject::kHeaderSize, | 1078                                           JSObject::kHeaderSize, | 
| 1075                                           prototype, | 1079                                           prototype, | 
| 1076                                           code, | 1080                                           code, | 
| 1077                                           false); | 1081                                           false); | 
| 1078     ASSERT(!function->has_initial_map()); | 1082     ASSERT(!function->has_initial_map()); | 
| 1079     function->shared()->set_instance_class_name(*symbol); | 1083     function->shared()->set_instance_class_name(*symbol); | 
| 1080     function->shared()->set_expected_nof_properties(2); | 1084     function->shared()->set_expected_nof_properties(2); | 
| 1081     Handle<JSObject> result = factory->NewJSObject(function); | 1085     Handle<JSObject> result = factory->NewJSObject(function); | 
| 1082 | 1086 | 
| 1083     global_context()->set_arguments_boilerplate(*result); | 1087     global_context()->set_arguments_boilerplate(*result); | 
| 1084     // Note: length must be added as the first property and | 1088     // Note: length must be added as the first property and | 
| 1085     //       callee must be added as the second property. | 1089     //       callee must be added as the second property. | 
| 1086     SetLocalPropertyNoThrow(result, factory->length_symbol(), | 1090     CHECK_NOT_EMPTY_HANDLE(isolate, | 
| 1087                             factory->undefined_value(), | 1091                            JSObject::SetLocalPropertyIgnoreAttributes( | 
| 1088                             DONT_ENUM); | 1092                                result, factory->length_symbol(), | 
| 1089     SetLocalPropertyNoThrow(result, factory->callee_symbol(), | 1093                                factory->undefined_value(), DONT_ENUM)); | 
| 1090                             factory->undefined_value(), | 1094     CHECK_NOT_EMPTY_HANDLE(isolate, | 
| 1091                             DONT_ENUM); | 1095                            JSObject::SetLocalPropertyIgnoreAttributes( | 
|  | 1096                                result, factory->callee_symbol(), | 
|  | 1097                                factory->undefined_value(), DONT_ENUM)); | 
| 1092 | 1098 | 
| 1093 #ifdef DEBUG | 1099 #ifdef DEBUG | 
| 1094     LookupResult lookup(isolate); | 1100     LookupResult lookup(isolate); | 
| 1095     result->LocalLookup(heap->callee_symbol(), &lookup); | 1101     result->LocalLookup(heap->callee_symbol(), &lookup); | 
| 1096     ASSERT(lookup.IsProperty() && (lookup.type() == FIELD)); | 1102     ASSERT(lookup.IsProperty() && (lookup.type() == FIELD)); | 
| 1097     ASSERT(lookup.GetFieldIndex() == Heap::kArgumentsCalleeIndex); | 1103     ASSERT(lookup.GetFieldIndex() == Heap::kArgumentsCalleeIndex); | 
| 1098 | 1104 | 
| 1099     result->LocalLookup(heap->length_symbol(), &lookup); | 1105     result->LocalLookup(heap->length_symbol(), &lookup); | 
| 1100     ASSERT(lookup.IsProperty() && (lookup.type() == FIELD)); | 1106     ASSERT(lookup.IsProperty() && (lookup.type() == FIELD)); | 
| 1101     ASSERT(lookup.GetFieldIndex() == Heap::kArgumentsLengthIndex); | 1107     ASSERT(lookup.GetFieldIndex() == Heap::kArgumentsLengthIndex); | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 1129     result->set_elements(*elements); | 1135     result->set_elements(*elements); | 
| 1130     ASSERT(result->HasNonStrictArgumentsElements()); | 1136     ASSERT(result->HasNonStrictArgumentsElements()); | 
| 1131     global_context()->set_aliased_arguments_boilerplate(*result); | 1137     global_context()->set_aliased_arguments_boilerplate(*result); | 
| 1132   } | 1138   } | 
| 1133 | 1139 | 
| 1134   {  // --- strict mode arguments boilerplate | 1140   {  // --- strict mode arguments boilerplate | 
| 1135     const PropertyAttributes attributes = | 1141     const PropertyAttributes attributes = | 
| 1136       static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 1142       static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 
| 1137 | 1143 | 
| 1138     // Create the ThrowTypeError functions. | 1144     // Create the ThrowTypeError functions. | 
| 1139     Handle<FixedArray> callee = factory->NewFixedArray(2, TENURED); | 1145     Handle<AccessorPair> callee = factory->NewAccessorPair(); | 
| 1140     Handle<FixedArray> caller = factory->NewFixedArray(2, TENURED); | 1146     Handle<AccessorPair> caller = factory->NewAccessorPair(); | 
| 1141 | 1147 | 
| 1142     Handle<JSFunction> throw_function = | 1148     Handle<JSFunction> throw_function = | 
| 1143         GetThrowTypeErrorFunction(); | 1149         GetThrowTypeErrorFunction(); | 
| 1144 | 1150 | 
| 1145     // Install the ThrowTypeError functions. | 1151     // Install the ThrowTypeError functions. | 
| 1146     callee->set(0, *throw_function); | 1152     callee->set_getter(*throw_function); | 
| 1147     callee->set(1, *throw_function); | 1153     callee->set_setter(*throw_function); | 
| 1148     caller->set(0, *throw_function); | 1154     caller->set_getter(*throw_function); | 
| 1149     caller->set(1, *throw_function); | 1155     caller->set_setter(*throw_function); | 
| 1150 | 1156 | 
| 1151     // Create the descriptor array for the arguments object. | 1157     // Create the descriptor array for the arguments object. | 
| 1152     Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(3); | 1158     Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(3); | 
| 1153     DescriptorArray::WhitenessWitness witness(*descriptors); | 1159     DescriptorArray::WhitenessWitness witness(*descriptors); | 
| 1154     {  // length | 1160     {  // length | 
| 1155       FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM); | 1161       FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM); | 
| 1156       descriptors->Set(0, &d, witness); | 1162       descriptors->Set(0, &d, witness); | 
| 1157     } | 1163     } | 
| 1158     {  // callee | 1164     {  // callee | 
| 1159       CallbacksDescriptor d(*factory->callee_symbol(), *callee, attributes); | 1165       CallbacksDescriptor d(*factory->callee_symbol(), *callee, attributes); | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 1176 | 1182 | 
| 1177     // Copy constructor from the non-strict arguments boilerplate. | 1183     // Copy constructor from the non-strict arguments boilerplate. | 
| 1178     map->set_constructor( | 1184     map->set_constructor( | 
| 1179       global_context()->arguments_boilerplate()->map()->constructor()); | 1185       global_context()->arguments_boilerplate()->map()->constructor()); | 
| 1180 | 1186 | 
| 1181     // Allocate the arguments boilerplate object. | 1187     // Allocate the arguments boilerplate object. | 
| 1182     Handle<JSObject> result = factory->NewJSObjectFromMap(map); | 1188     Handle<JSObject> result = factory->NewJSObjectFromMap(map); | 
| 1183     global_context()->set_strict_mode_arguments_boilerplate(*result); | 1189     global_context()->set_strict_mode_arguments_boilerplate(*result); | 
| 1184 | 1190 | 
| 1185     // Add length property only for strict mode boilerplate. | 1191     // Add length property only for strict mode boilerplate. | 
| 1186     SetLocalPropertyNoThrow(result, factory->length_symbol(), | 1192     CHECK_NOT_EMPTY_HANDLE(isolate, | 
| 1187                             factory->undefined_value(), | 1193                            JSObject::SetLocalPropertyIgnoreAttributes( | 
| 1188                             DONT_ENUM); | 1194                                result, factory->length_symbol(), | 
|  | 1195                                factory->undefined_value(), DONT_ENUM)); | 
| 1189 | 1196 | 
| 1190 #ifdef DEBUG | 1197 #ifdef DEBUG | 
| 1191     LookupResult lookup(isolate); | 1198     LookupResult lookup(isolate); | 
| 1192     result->LocalLookup(heap->length_symbol(), &lookup); | 1199     result->LocalLookup(heap->length_symbol(), &lookup); | 
| 1193     ASSERT(lookup.IsProperty() && (lookup.type() == FIELD)); | 1200     ASSERT(lookup.IsProperty() && (lookup.type() == FIELD)); | 
| 1194     ASSERT(lookup.GetFieldIndex() == Heap::kArgumentsLengthIndex); | 1201     ASSERT(lookup.GetFieldIndex() == Heap::kArgumentsLengthIndex); | 
| 1195 | 1202 | 
| 1196     ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex); | 1203     ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex); | 
| 1197 | 1204 | 
| 1198     // Check the state of the object. | 1205     // Check the state of the object. | 
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1346         0, | 1353         0, | 
| 1347         0, | 1354         0, | 
| 1348         extension, | 1355         extension, | 
| 1349         NULL, | 1356         NULL, | 
| 1350         Handle<String>::null(), | 1357         Handle<String>::null(), | 
| 1351         use_runtime_context ? NATIVES_CODE : NOT_NATIVES_CODE); | 1358         use_runtime_context ? NATIVES_CODE : NOT_NATIVES_CODE); | 
| 1352     if (function_info.is_null()) return false; | 1359     if (function_info.is_null()) return false; | 
| 1353     if (cache != NULL) cache->Add(name, function_info); | 1360     if (cache != NULL) cache->Add(name, function_info); | 
| 1354   } | 1361   } | 
| 1355 | 1362 | 
| 1356   // Setup the function context. Conceptually, we should clone the | 1363   // Set up the function context. Conceptually, we should clone the | 
| 1357   // function before overwriting the context but since we're in a | 1364   // function before overwriting the context but since we're in a | 
| 1358   // single-threaded environment it is not strictly necessary. | 1365   // single-threaded environment it is not strictly necessary. | 
| 1359   ASSERT(top_context->IsGlobalContext()); | 1366   ASSERT(top_context->IsGlobalContext()); | 
| 1360   Handle<Context> context = | 1367   Handle<Context> context = | 
| 1361       Handle<Context>(use_runtime_context | 1368       Handle<Context>(use_runtime_context | 
| 1362                       ? Handle<Context>(top_context->runtime_context()) | 1369                       ? Handle<Context>(top_context->runtime_context()) | 
| 1363                       : top_context); | 1370                       : top_context); | 
| 1364   Handle<JSFunction> fun = | 1371   Handle<JSFunction> fun = | 
| 1365       factory->NewFunctionFromSharedFunctionInfo(function_info, context); | 1372       factory->NewFunctionFromSharedFunctionInfo(function_info, context); | 
| 1366 | 1373 | 
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1433   Handle<String> name = factory()->LookupAsciiSymbol("builtins"); | 1440   Handle<String> name = factory()->LookupAsciiSymbol("builtins"); | 
| 1434   builtins_fun->shared()->set_instance_class_name(*name); | 1441   builtins_fun->shared()->set_instance_class_name(*name); | 
| 1435 | 1442 | 
| 1436   // Allocate the builtins object. | 1443   // Allocate the builtins object. | 
| 1437   Handle<JSBuiltinsObject> builtins = | 1444   Handle<JSBuiltinsObject> builtins = | 
| 1438       Handle<JSBuiltinsObject>::cast(factory()->NewGlobalObject(builtins_fun)); | 1445       Handle<JSBuiltinsObject>::cast(factory()->NewGlobalObject(builtins_fun)); | 
| 1439   builtins->set_builtins(*builtins); | 1446   builtins->set_builtins(*builtins); | 
| 1440   builtins->set_global_context(*global_context()); | 1447   builtins->set_global_context(*global_context()); | 
| 1441   builtins->set_global_receiver(*builtins); | 1448   builtins->set_global_receiver(*builtins); | 
| 1442 | 1449 | 
| 1443   // Setup the 'global' properties of the builtins object. The | 1450   // Set up the 'global' properties of the builtins object. The | 
| 1444   // 'global' property that refers to the global object is the only | 1451   // 'global' property that refers to the global object is the only | 
| 1445   // way to get from code running in the builtins context to the | 1452   // way to get from code running in the builtins context to the | 
| 1446   // global object. | 1453   // global object. | 
| 1447   static const PropertyAttributes attributes = | 1454   static const PropertyAttributes attributes = | 
| 1448       static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); | 1455       static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); | 
| 1449   Handle<String> global_symbol = factory()->LookupAsciiSymbol("global"); | 1456   Handle<String> global_symbol = factory()->LookupAsciiSymbol("global"); | 
| 1450   Handle<Object> global_obj(global_context()->global()); | 1457   Handle<Object> global_obj(global_context()->global()); | 
| 1451   SetLocalPropertyNoThrow(builtins, global_symbol, global_obj, attributes); | 1458   CHECK_NOT_EMPTY_HANDLE(isolate(), | 
|  | 1459                          JSObject::SetLocalPropertyIgnoreAttributes( | 
|  | 1460                              builtins, global_symbol, global_obj, attributes)); | 
| 1452 | 1461 | 
| 1453   // Setup the reference from the global object to the builtins object. | 1462   // Set up the reference from the global object to the builtins object. | 
| 1454   JSGlobalObject::cast(global_context()->global())->set_builtins(*builtins); | 1463   JSGlobalObject::cast(global_context()->global())->set_builtins(*builtins); | 
| 1455 | 1464 | 
| 1456   // Create a bridge function that has context in the global context. | 1465   // Create a bridge function that has context in the global context. | 
| 1457   Handle<JSFunction> bridge = | 1466   Handle<JSFunction> bridge = | 
| 1458       factory()->NewFunction(factory()->empty_symbol(), | 1467       factory()->NewFunction(factory()->empty_symbol(), | 
| 1459                              factory()->undefined_value()); | 1468                              factory()->undefined_value()); | 
| 1460   ASSERT(bridge->context() == *isolate()->global_context()); | 1469   ASSERT(bridge->context() == *isolate()->global_context()); | 
| 1461 | 1470 | 
| 1462   // Allocate the builtins context. | 1471   // Allocate the builtins context. | 
| 1463   Handle<Context> context = | 1472   Handle<Context> context = | 
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1667     if (!CompileBuiltin(isolate(), i)) return false; | 1676     if (!CompileBuiltin(isolate(), i)) return false; | 
| 1668     // TODO(ager): We really only need to install the JS builtin | 1677     // TODO(ager): We really only need to install the JS builtin | 
| 1669     // functions on the builtins object after compiling and running | 1678     // functions on the builtins object after compiling and running | 
| 1670     // runtime.js. | 1679     // runtime.js. | 
| 1671     if (!InstallJSBuiltins(builtins)) return false; | 1680     if (!InstallJSBuiltins(builtins)) return false; | 
| 1672   } | 1681   } | 
| 1673 | 1682 | 
| 1674   InstallNativeFunctions(); | 1683   InstallNativeFunctions(); | 
| 1675 | 1684 | 
| 1676   // Store the map for the string prototype after the natives has been compiled | 1685   // Store the map for the string prototype after the natives has been compiled | 
| 1677   // and the String function has been setup. | 1686   // and the String function has been set up. | 
| 1678   Handle<JSFunction> string_function(global_context()->string_function()); | 1687   Handle<JSFunction> string_function(global_context()->string_function()); | 
| 1679   ASSERT(JSObject::cast( | 1688   ASSERT(JSObject::cast( | 
| 1680       string_function->initial_map()->prototype())->HasFastProperties()); | 1689       string_function->initial_map()->prototype())->HasFastProperties()); | 
| 1681   global_context()->set_string_function_prototype_map( | 1690   global_context()->set_string_function_prototype_map( | 
| 1682       HeapObject::cast(string_function->initial_map()->prototype())->map()); | 1691       HeapObject::cast(string_function->initial_map()->prototype())->map()); | 
| 1683 | 1692 | 
| 1684   // Install Function.prototype.call and apply. | 1693   // Install Function.prototype.call and apply. | 
| 1685   { Handle<String> key = factory()->function_class_symbol(); | 1694   { Handle<String> key = factory()->function_class_symbol(); | 
| 1686     Handle<JSFunction> function = | 1695     Handle<JSFunction> function = | 
| 1687         Handle<JSFunction>::cast(GetProperty(isolate()->global(), key)); | 1696         Handle<JSFunction>::cast(GetProperty(isolate()->global(), key)); | 
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1904   BootstrapperActive active; | 1913   BootstrapperActive active; | 
| 1905   SaveContext saved_context(isolate); | 1914   SaveContext saved_context(isolate); | 
| 1906   isolate->set_context(*global_context); | 1915   isolate->set_context(*global_context); | 
| 1907   if (!Genesis::InstallExtensions(global_context, extensions)) return false; | 1916   if (!Genesis::InstallExtensions(global_context, extensions)) return false; | 
| 1908   Genesis::InstallSpecialObjects(global_context); | 1917   Genesis::InstallSpecialObjects(global_context); | 
| 1909   return true; | 1918   return true; | 
| 1910 } | 1919 } | 
| 1911 | 1920 | 
| 1912 | 1921 | 
| 1913 void Genesis::InstallSpecialObjects(Handle<Context> global_context) { | 1922 void Genesis::InstallSpecialObjects(Handle<Context> global_context) { | 
| 1914   Factory* factory = global_context->GetIsolate()->factory(); | 1923   Isolate* isolate = global_context->GetIsolate(); | 
|  | 1924   Factory* factory = isolate->factory(); | 
| 1915   HandleScope scope; | 1925   HandleScope scope; | 
| 1916   Handle<JSGlobalObject> js_global( | 1926   Handle<JSGlobalObject> global(JSGlobalObject::cast(global_context->global())); | 
| 1917       JSGlobalObject::cast(global_context->global())); |  | 
| 1918   // Expose the natives in global if a name for it is specified. | 1927   // Expose the natives in global if a name for it is specified. | 
| 1919   if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) { | 1928   if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) { | 
| 1920     Handle<String> natives_string = | 1929     Handle<String> natives = factory->LookupAsciiSymbol(FLAG_expose_natives_as); | 
| 1921         factory->LookupAsciiSymbol(FLAG_expose_natives_as); | 1930     CHECK_NOT_EMPTY_HANDLE(isolate, | 
| 1922     SetLocalPropertyNoThrow(js_global, natives_string, | 1931                            JSObject::SetLocalPropertyIgnoreAttributes( | 
| 1923                             Handle<JSObject>(js_global->builtins()), DONT_ENUM); | 1932                                global, natives, | 
|  | 1933                                Handle<JSObject>(global->builtins()), | 
|  | 1934                                DONT_ENUM)); | 
| 1924   } | 1935   } | 
| 1925 | 1936 | 
| 1926   Handle<Object> Error = GetProperty(js_global, "Error"); | 1937   Handle<Object> Error = GetProperty(global, "Error"); | 
| 1927   if (Error->IsJSObject()) { | 1938   if (Error->IsJSObject()) { | 
| 1928     Handle<String> name = factory->LookupAsciiSymbol("stackTraceLimit"); | 1939     Handle<String> name = factory->LookupAsciiSymbol("stackTraceLimit"); | 
| 1929     SetLocalPropertyNoThrow(Handle<JSObject>::cast(Error), | 1940     Handle<Smi> stack_trace_limit(Smi::FromInt(FLAG_stack_trace_limit)); | 
| 1930                             name, | 1941     CHECK_NOT_EMPTY_HANDLE(isolate, | 
| 1931                             Handle<Smi>(Smi::FromInt(FLAG_stack_trace_limit)), | 1942                            JSObject::SetLocalPropertyIgnoreAttributes( | 
| 1932                             NONE); | 1943                                Handle<JSObject>::cast(Error), name, | 
|  | 1944                                stack_trace_limit, NONE)); | 
| 1933   } | 1945   } | 
| 1934 | 1946 | 
| 1935 #ifdef ENABLE_DEBUGGER_SUPPORT | 1947 #ifdef ENABLE_DEBUGGER_SUPPORT | 
| 1936   // Expose the debug global object in global if a name for it is specified. | 1948   // Expose the debug global object in global if a name for it is specified. | 
| 1937   if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) { | 1949   if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) { | 
| 1938     Debug* debug = Isolate::Current()->debug(); | 1950     Debug* debug = Isolate::Current()->debug(); | 
| 1939     // If loading fails we just bail out without installing the | 1951     // If loading fails we just bail out without installing the | 
| 1940     // debugger but without tanking the whole context. | 1952     // debugger but without tanking the whole context. | 
| 1941     if (!debug->Load()) return; | 1953     if (!debug->Load()) return; | 
| 1942     // Set the security token for the debugger context to the same as | 1954     // Set the security token for the debugger context to the same as | 
| 1943     // the shell global context to allow calling between these (otherwise | 1955     // the shell global context to allow calling between these (otherwise | 
| 1944     // exposing debug global object doesn't make much sense). | 1956     // exposing debug global object doesn't make much sense). | 
| 1945     debug->debug_context()->set_security_token( | 1957     debug->debug_context()->set_security_token( | 
| 1946         global_context->security_token()); | 1958         global_context->security_token()); | 
| 1947 | 1959 | 
| 1948     Handle<String> debug_string = | 1960     Handle<String> debug_string = | 
| 1949         factory->LookupAsciiSymbol(FLAG_expose_debug_as); | 1961         factory->LookupAsciiSymbol(FLAG_expose_debug_as); | 
| 1950     Handle<Object> global_proxy(debug->debug_context()->global_proxy()); | 1962     Handle<Object> global_proxy(debug->debug_context()->global_proxy()); | 
| 1951     SetLocalPropertyNoThrow(js_global, debug_string, global_proxy, DONT_ENUM); | 1963     CHECK_NOT_EMPTY_HANDLE(isolate, | 
|  | 1964                            JSObject::SetLocalPropertyIgnoreAttributes( | 
|  | 1965                                global, debug_string, global_proxy, DONT_ENUM)); | 
| 1952   } | 1966   } | 
| 1953 #endif | 1967 #endif | 
| 1954 } | 1968 } | 
| 1955 | 1969 | 
| 1956 static uint32_t Hash(RegisteredExtension* extension) { | 1970 static uint32_t Hash(RegisteredExtension* extension) { | 
| 1957   return v8::internal::ComputePointerHash(extension); | 1971   return v8::internal::ComputePointerHash(extension); | 
| 1958 } | 1972 } | 
| 1959 | 1973 | 
| 1960 static bool MatchRegisteredExtensions(void* key1, void* key2) { | 1974 static bool MatchRegisteredExtensions(void* key1, void* key2) { | 
| 1961   return key1 == key2; | 1975   return key1 == key2; | 
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2157     Handle<DescriptorArray> descs = | 2171     Handle<DescriptorArray> descs = | 
| 2158         Handle<DescriptorArray>(from->map()->instance_descriptors()); | 2172         Handle<DescriptorArray>(from->map()->instance_descriptors()); | 
| 2159     for (int i = 0; i < descs->number_of_descriptors(); i++) { | 2173     for (int i = 0; i < descs->number_of_descriptors(); i++) { | 
| 2160       PropertyDetails details = PropertyDetails(descs->GetDetails(i)); | 2174       PropertyDetails details = PropertyDetails(descs->GetDetails(i)); | 
| 2161       switch (details.type()) { | 2175       switch (details.type()) { | 
| 2162         case FIELD: { | 2176         case FIELD: { | 
| 2163           HandleScope inner; | 2177           HandleScope inner; | 
| 2164           Handle<String> key = Handle<String>(descs->GetKey(i)); | 2178           Handle<String> key = Handle<String>(descs->GetKey(i)); | 
| 2165           int index = descs->GetFieldIndex(i); | 2179           int index = descs->GetFieldIndex(i); | 
| 2166           Handle<Object> value = Handle<Object>(from->FastPropertyAt(index)); | 2180           Handle<Object> value = Handle<Object>(from->FastPropertyAt(index)); | 
| 2167           SetLocalPropertyNoThrow(to, key, value, details.attributes()); | 2181           CHECK_NOT_EMPTY_HANDLE(to->GetIsolate(), | 
|  | 2182                                  JSObject::SetLocalPropertyIgnoreAttributes( | 
|  | 2183                                      to, key, value, details.attributes())); | 
| 2168           break; | 2184           break; | 
| 2169         } | 2185         } | 
| 2170         case CONSTANT_FUNCTION: { | 2186         case CONSTANT_FUNCTION: { | 
| 2171           HandleScope inner; | 2187           HandleScope inner; | 
| 2172           Handle<String> key = Handle<String>(descs->GetKey(i)); | 2188           Handle<String> key = Handle<String>(descs->GetKey(i)); | 
| 2173           Handle<JSFunction> fun = | 2189           Handle<JSFunction> fun = | 
| 2174               Handle<JSFunction>(descs->GetConstantFunction(i)); | 2190               Handle<JSFunction>(descs->GetConstantFunction(i)); | 
| 2175           SetLocalPropertyNoThrow(to, key, fun, details.attributes()); | 2191           CHECK_NOT_EMPTY_HANDLE(to->GetIsolate(), | 
|  | 2192                                  JSObject::SetLocalPropertyIgnoreAttributes( | 
|  | 2193                                      to, key, fun, details.attributes())); | 
| 2176           break; | 2194           break; | 
| 2177         } | 2195         } | 
| 2178         case CALLBACKS: { | 2196         case CALLBACKS: { | 
| 2179           LookupResult result(isolate()); | 2197           LookupResult result(isolate()); | 
| 2180           to->LocalLookup(descs->GetKey(i), &result); | 2198           to->LocalLookup(descs->GetKey(i), &result); | 
| 2181           // If the property is already there we skip it | 2199           // If the property is already there we skip it | 
| 2182           if (result.IsProperty()) continue; | 2200           if (result.IsProperty()) continue; | 
| 2183           HandleScope inner; | 2201           HandleScope inner; | 
| 2184           ASSERT(!to->HasFastProperties()); | 2202           ASSERT(!to->HasFastProperties()); | 
| 2185           // Add to dictionary. | 2203           // Add to dictionary. | 
| 2186           Handle<String> key = Handle<String>(descs->GetKey(i)); | 2204           Handle<String> key = Handle<String>(descs->GetKey(i)); | 
| 2187           Handle<Object> callbacks(descs->GetCallbacksObject(i)); | 2205           Handle<Object> callbacks(descs->GetCallbacksObject(i)); | 
| 2188           PropertyDetails d = | 2206           PropertyDetails d = | 
| 2189               PropertyDetails(details.attributes(), CALLBACKS, details.index()); | 2207               PropertyDetails(details.attributes(), CALLBACKS, details.index()); | 
| 2190           SetNormalizedProperty(to, key, callbacks, d); | 2208           JSObject::SetNormalizedProperty(to, key, callbacks, d); | 
| 2191           break; | 2209           break; | 
| 2192         } | 2210         } | 
| 2193         case MAP_TRANSITION: | 2211         case MAP_TRANSITION: | 
| 2194         case ELEMENTS_TRANSITION: | 2212         case ELEMENTS_TRANSITION: | 
| 2195         case CONSTANT_TRANSITION: | 2213         case CONSTANT_TRANSITION: | 
| 2196         case NULL_DESCRIPTOR: | 2214         case NULL_DESCRIPTOR: | 
| 2197           // Ignore non-properties. | 2215           // Ignore non-properties. | 
| 2198           break; | 2216           break; | 
| 2199         case NORMAL: | 2217         case NORMAL: | 
| 2200           // Do not occur since the from object has fast properties. | 2218           // Do not occur since the from object has fast properties. | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 2217         LookupResult result(isolate()); | 2235         LookupResult result(isolate()); | 
| 2218         to->LocalLookup(String::cast(raw_key), &result); | 2236         to->LocalLookup(String::cast(raw_key), &result); | 
| 2219         if (result.IsProperty()) continue; | 2237         if (result.IsProperty()) continue; | 
| 2220         // Set the property. | 2238         // Set the property. | 
| 2221         Handle<String> key = Handle<String>(String::cast(raw_key)); | 2239         Handle<String> key = Handle<String>(String::cast(raw_key)); | 
| 2222         Handle<Object> value = Handle<Object>(properties->ValueAt(i)); | 2240         Handle<Object> value = Handle<Object>(properties->ValueAt(i)); | 
| 2223         if (value->IsJSGlobalPropertyCell()) { | 2241         if (value->IsJSGlobalPropertyCell()) { | 
| 2224           value = Handle<Object>(JSGlobalPropertyCell::cast(*value)->value()); | 2242           value = Handle<Object>(JSGlobalPropertyCell::cast(*value)->value()); | 
| 2225         } | 2243         } | 
| 2226         PropertyDetails details = properties->DetailsAt(i); | 2244         PropertyDetails details = properties->DetailsAt(i); | 
| 2227         SetLocalPropertyNoThrow(to, key, value, details.attributes()); | 2245         CHECK_NOT_EMPTY_HANDLE(to->GetIsolate(), | 
|  | 2246                                JSObject::SetLocalPropertyIgnoreAttributes( | 
|  | 2247                                    to, key, value, details.attributes())); | 
| 2228       } | 2248       } | 
| 2229     } | 2249     } | 
| 2230   } | 2250   } | 
| 2231 } | 2251 } | 
| 2232 | 2252 | 
| 2233 | 2253 | 
| 2234 void Genesis::TransferIndexedProperties(Handle<JSObject> from, | 2254 void Genesis::TransferIndexedProperties(Handle<JSObject> from, | 
| 2235                                         Handle<JSObject> to) { | 2255                                         Handle<JSObject> to) { | 
| 2236   // Cloning the elements array is sufficient. | 2256   // Cloning the elements array is sufficient. | 
| 2237   Handle<FixedArray> from_elements = | 2257   Handle<FixedArray> from_elements = | 
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2354   return from + sizeof(NestingCounterType); | 2374   return from + sizeof(NestingCounterType); | 
| 2355 } | 2375 } | 
| 2356 | 2376 | 
| 2357 | 2377 | 
| 2358 // Called when the top-level V8 mutex is destroyed. | 2378 // Called when the top-level V8 mutex is destroyed. | 
| 2359 void Bootstrapper::FreeThreadResources() { | 2379 void Bootstrapper::FreeThreadResources() { | 
| 2360   ASSERT(!IsActive()); | 2380   ASSERT(!IsActive()); | 
| 2361 } | 2381 } | 
| 2362 | 2382 | 
| 2363 } }  // namespace v8::internal | 2383 } }  // namespace v8::internal | 
| OLD | NEW | 
|---|