| OLD | NEW |
| 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 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 DescriptorArray::WhitenessWitness witness(*descriptors); | 531 DescriptorArray::WhitenessWitness witness(*descriptors); |
| 532 | 532 |
| 533 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength)); | 533 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength)); |
| 534 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName)); | 534 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName)); |
| 535 Handle<AccessorPair> arguments(factory()->NewAccessorPair()); | 535 Handle<AccessorPair> arguments(factory()->NewAccessorPair()); |
| 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 rw_attribs = |
| 542 DONT_ENUM | DONT_DELETE); | 542 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); |
| 543 PropertyAttributes ro_attribs = |
| 544 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 543 map->set_instance_descriptors(*descriptors); | 545 map->set_instance_descriptors(*descriptors); |
| 544 | 546 |
| 545 { // Add length. | 547 { // Add length. |
| 546 CallbacksDescriptor d(*factory()->length_string(), *length, attribs); | 548 CallbacksDescriptor d(*factory()->length_string(), *length, ro_attribs); |
| 547 map->AppendDescriptor(&d, witness); | 549 map->AppendDescriptor(&d, witness); |
| 548 } | 550 } |
| 549 { // Add name. | 551 { // Add name. |
| 550 CallbacksDescriptor d(*factory()->name_string(), *name, attribs); | 552 CallbacksDescriptor d(*factory()->name_string(), *name, rw_attribs); |
| 551 map->AppendDescriptor(&d, witness); | 553 map->AppendDescriptor(&d, witness); |
| 552 } | 554 } |
| 553 { // Add arguments. | 555 { // Add arguments. |
| 554 CallbacksDescriptor d(*factory()->arguments_string(), *arguments, attribs); | 556 CallbacksDescriptor d(*factory()->arguments_string(), *arguments, |
| 557 rw_attribs); |
| 555 map->AppendDescriptor(&d, witness); | 558 map->AppendDescriptor(&d, witness); |
| 556 } | 559 } |
| 557 { // Add caller. | 560 { // Add caller. |
| 558 CallbacksDescriptor d(*factory()->caller_string(), *caller, attribs); | 561 CallbacksDescriptor d(*factory()->caller_string(), *caller, rw_attribs); |
| 559 map->AppendDescriptor(&d, witness); | 562 map->AppendDescriptor(&d, witness); |
| 560 } | 563 } |
| 561 if (prototypeMode != DONT_ADD_PROTOTYPE) { | 564 if (prototypeMode != DONT_ADD_PROTOTYPE) { |
| 562 // Add prototype. | 565 // Add prototype. |
| 563 if (prototypeMode != ADD_WRITEABLE_PROTOTYPE) { | 566 PropertyAttributes attribs = |
| 564 attribs = static_cast<PropertyAttributes>(attribs | READ_ONLY); | 567 prototypeMode == ADD_WRITEABLE_PROTOTYPE ? rw_attribs : ro_attribs; |
| 565 } | |
| 566 CallbacksDescriptor d(*factory()->prototype_string(), *prototype, attribs); | 568 CallbacksDescriptor d(*factory()->prototype_string(), *prototype, attribs); |
| 567 map->AppendDescriptor(&d, witness); | 569 map->AppendDescriptor(&d, witness); |
| 568 } | 570 } |
| 569 } | 571 } |
| 570 | 572 |
| 571 | 573 |
| 572 // ECMAScript 5th Edition, 13.2.3 | 574 // ECMAScript 5th Edition, 13.2.3 |
| 573 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() { | 575 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() { |
| 574 if (throw_type_error_function.is_null()) { | 576 if (throw_type_error_function.is_null()) { |
| 575 Handle<String> name = factory()->InternalizeOneByteString( | 577 Handle<String> name = factory()->InternalizeOneByteString( |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 // Install global Function object | 852 // Install global Function object |
| 851 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, | 853 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, |
| 852 empty_function, Builtins::kIllegal, true, true); | 854 empty_function, Builtins::kIllegal, true, true); |
| 853 | 855 |
| 854 { // --- A r r a y --- | 856 { // --- A r r a y --- |
| 855 Handle<JSFunction> array_function = | 857 Handle<JSFunction> array_function = |
| 856 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, | 858 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, |
| 857 isolate->initial_object_prototype(), | 859 isolate->initial_object_prototype(), |
| 858 Builtins::kArrayCode, true, true); | 860 Builtins::kArrayCode, true, true); |
| 859 array_function->shared()->DontAdaptArguments(); | 861 array_function->shared()->DontAdaptArguments(); |
| 862 array_function->shared()->set_function_data(Smi::FromInt(kArrayCode)); |
| 860 | 863 |
| 861 // This seems a bit hackish, but we need to make sure Array.length | 864 // This seems a bit hackish, but we need to make sure Array.length |
| 862 // is 1. | 865 // is 1. |
| 863 array_function->shared()->set_length(1); | 866 array_function->shared()->set_length(1); |
| 864 | 867 |
| 865 Handle<Map> initial_map(array_function->initial_map()); | 868 Handle<Map> initial_map(array_function->initial_map()); |
| 866 Handle<DescriptorArray> array_descriptors( | 869 Handle<DescriptorArray> array_descriptors( |
| 867 factory->NewDescriptorArray(0, 1)); | 870 factory->NewDescriptorArray(0, 1)); |
| 868 DescriptorArray::WhitenessWitness witness(*array_descriptors); | 871 DescriptorArray::WhitenessWitness witness(*array_descriptors); |
| 869 | 872 |
| (...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2492 if (properties->IsKey(raw_key)) { | 2495 if (properties->IsKey(raw_key)) { |
| 2493 ASSERT(raw_key->IsName()); | 2496 ASSERT(raw_key->IsName()); |
| 2494 // If the property is already there we skip it. | 2497 // If the property is already there we skip it. |
| 2495 LookupResult result(isolate()); | 2498 LookupResult result(isolate()); |
| 2496 to->LocalLookup(Name::cast(raw_key), &result); | 2499 to->LocalLookup(Name::cast(raw_key), &result); |
| 2497 if (result.IsFound()) continue; | 2500 if (result.IsFound()) continue; |
| 2498 // Set the property. | 2501 // Set the property. |
| 2499 Handle<Name> key = Handle<Name>(Name::cast(raw_key)); | 2502 Handle<Name> key = Handle<Name>(Name::cast(raw_key)); |
| 2500 Handle<Object> value = Handle<Object>(properties->ValueAt(i), | 2503 Handle<Object> value = Handle<Object>(properties->ValueAt(i), |
| 2501 isolate()); | 2504 isolate()); |
| 2502 if (value->IsJSGlobalPropertyCell()) { | 2505 ASSERT(!value->IsCell()); |
| 2503 value = Handle<Object>(JSGlobalPropertyCell::cast(*value)->value(), | 2506 if (value->IsPropertyCell()) { |
| 2507 value = Handle<Object>(PropertyCell::cast(*value)->value(), |
| 2504 isolate()); | 2508 isolate()); |
| 2505 } | 2509 } |
| 2506 PropertyDetails details = properties->DetailsAt(i); | 2510 PropertyDetails details = properties->DetailsAt(i); |
| 2507 CHECK_NOT_EMPTY_HANDLE(isolate(), | 2511 CHECK_NOT_EMPTY_HANDLE(isolate(), |
| 2508 JSObject::SetLocalPropertyIgnoreAttributes( | 2512 JSObject::SetLocalPropertyIgnoreAttributes( |
| 2509 to, key, value, details.attributes())); | 2513 to, key, value, details.attributes())); |
| 2510 } | 2514 } |
| 2511 } | 2515 } |
| 2512 } | 2516 } |
| 2513 } | 2517 } |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2641 return from + sizeof(NestingCounterType); | 2645 return from + sizeof(NestingCounterType); |
| 2642 } | 2646 } |
| 2643 | 2647 |
| 2644 | 2648 |
| 2645 // Called when the top-level V8 mutex is destroyed. | 2649 // Called when the top-level V8 mutex is destroyed. |
| 2646 void Bootstrapper::FreeThreadResources() { | 2650 void Bootstrapper::FreeThreadResources() { |
| 2647 ASSERT(!IsActive()); | 2651 ASSERT(!IsActive()); |
| 2648 } | 2652 } |
| 2649 | 2653 |
| 2650 } } // namespace v8::internal | 2654 } } // namespace v8::internal |
| OLD | NEW |