| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 } | 305 } |
| 306 | 306 |
| 307 | 307 |
| 308 Handle<Object> Factory::NewError(const char* maker, | 308 Handle<Object> Factory::NewError(const char* maker, |
| 309 const char* type, | 309 const char* type, |
| 310 Handle<JSArray> args) { | 310 Handle<JSArray> args) { |
| 311 Handle<String> make_str = Factory::LookupAsciiSymbol(maker); | 311 Handle<String> make_str = Factory::LookupAsciiSymbol(maker); |
| 312 Handle<JSFunction> fun = | 312 Handle<JSFunction> fun = |
| 313 Handle<JSFunction>( | 313 Handle<JSFunction>( |
| 314 JSFunction::cast( | 314 JSFunction::cast( |
| 315 Top::security_context_builtins()->GetProperty(*make_str))); | 315 Top::builtins()->GetProperty(*make_str))); |
| 316 Handle<Object> type_obj = Factory::LookupAsciiSymbol(type); | 316 Handle<Object> type_obj = Factory::LookupAsciiSymbol(type); |
| 317 Object** argv[2] = { type_obj.location(), | 317 Object** argv[2] = { type_obj.location(), |
| 318 Handle<Object>::cast(args).location() }; | 318 Handle<Object>::cast(args).location() }; |
| 319 | 319 |
| 320 // Invoke the JavaScript factory method. If an exception is thrown while | 320 // Invoke the JavaScript factory method. If an exception is thrown while |
| 321 // running the factory method, use the exception as the result. | 321 // running the factory method, use the exception as the result. |
| 322 bool caught_exception; | 322 bool caught_exception; |
| 323 Handle<Object> result = Execution::TryCall(fun, | 323 Handle<Object> result = Execution::TryCall(fun, |
| 324 Top::security_context_builtins(), | 324 Top::builtins(), |
| 325 2, | 325 2, |
| 326 argv, | 326 argv, |
| 327 &caught_exception); | 327 &caught_exception); |
| 328 return result; | 328 return result; |
| 329 } | 329 } |
| 330 | 330 |
| 331 | 331 |
| 332 Handle<Object> Factory::NewError(Handle<String> message) { | 332 Handle<Object> Factory::NewError(Handle<String> message) { |
| 333 return NewError("$Error", message); | 333 return NewError("$Error", message); |
| 334 } | 334 } |
| 335 | 335 |
| 336 | 336 |
| 337 Handle<Object> Factory::NewError(const char* constructor, | 337 Handle<Object> Factory::NewError(const char* constructor, |
| 338 Handle<String> message) { | 338 Handle<String> message) { |
| 339 Handle<String> constr = Factory::LookupAsciiSymbol(constructor); | 339 Handle<String> constr = Factory::LookupAsciiSymbol(constructor); |
| 340 Handle<JSFunction> fun = | 340 Handle<JSFunction> fun = |
| 341 Handle<JSFunction>( | 341 Handle<JSFunction>( |
| 342 JSFunction::cast( | 342 JSFunction::cast( |
| 343 Top::security_context_builtins()->GetProperty(*constr))); | 343 Top::builtins()->GetProperty(*constr))); |
| 344 Object** argv[1] = { Handle<Object>::cast(message).location() }; | 344 Object** argv[1] = { Handle<Object>::cast(message).location() }; |
| 345 | 345 |
| 346 // Invoke the JavaScript factory method. If an exception is thrown while | 346 // Invoke the JavaScript factory method. If an exception is thrown while |
| 347 // running the factory method, use the exception as the result. | 347 // running the factory method, use the exception as the result. |
| 348 bool caught_exception; | 348 bool caught_exception; |
| 349 Handle<Object> result = Execution::TryCall(fun, | 349 Handle<Object> result = Execution::TryCall(fun, |
| 350 Top::security_context_builtins(), | 350 Top::builtins(), |
| 351 1, | 351 1, |
| 352 argv, | 352 argv, |
| 353 &caught_exception); | 353 &caught_exception); |
| 354 return result; | 354 return result; |
| 355 } | 355 } |
| 356 | 356 |
| 357 | 357 |
| 358 Handle<JSFunction> Factory::NewFunction(Handle<String> name, | 358 Handle<JSFunction> Factory::NewFunction(Handle<String> name, |
| 359 InstanceType type, | 359 InstanceType type, |
| 360 int instance_size, | 360 int instance_size, |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 } | 663 } |
| 664 | 664 |
| 665 | 665 |
| 666 Handle<JSObject> Factory::NewArgumentsObject(Handle<Object> callee, | 666 Handle<JSObject> Factory::NewArgumentsObject(Handle<Object> callee, |
| 667 int length) { | 667 int length) { |
| 668 CALL_HEAP_FUNCTION(Heap::AllocateArgumentsObject(*callee, length), JSObject); | 668 CALL_HEAP_FUNCTION(Heap::AllocateArgumentsObject(*callee, length), JSObject); |
| 669 } | 669 } |
| 670 | 670 |
| 671 | 671 |
| 672 Handle<JSFunction> Factory::CreateApiFunction( | 672 Handle<JSFunction> Factory::CreateApiFunction( |
| 673 Handle<FunctionTemplateInfo> obj, | 673 Handle<FunctionTemplateInfo> obj, ApiInstanceType instance_type) { |
| 674 bool is_global) { | |
| 675 Handle<Code> code = Handle<Code>(Builtins::builtin(Builtins::HandleApiCall)); | 674 Handle<Code> code = Handle<Code>(Builtins::builtin(Builtins::HandleApiCall)); |
| 676 | 675 |
| 677 int internal_field_count = 0; | 676 int internal_field_count = 0; |
| 678 if (!obj->instance_template()->IsUndefined()) { | 677 if (!obj->instance_template()->IsUndefined()) { |
| 679 Handle<ObjectTemplateInfo> instance_template = | 678 Handle<ObjectTemplateInfo> instance_template = |
| 680 Handle<ObjectTemplateInfo>( | 679 Handle<ObjectTemplateInfo>( |
| 681 ObjectTemplateInfo::cast(obj->instance_template())); | 680 ObjectTemplateInfo::cast(obj->instance_template())); |
| 682 internal_field_count = | 681 internal_field_count = |
| 683 Smi::cast(instance_template->internal_field_count())->value(); | 682 Smi::cast(instance_template->internal_field_count())->value(); |
| 684 } | 683 } |
| 685 | 684 |
| 686 int instance_size = kPointerSize * internal_field_count; | 685 int instance_size = kPointerSize * internal_field_count; |
| 687 if (is_global) { | 686 InstanceType type; |
| 688 instance_size += JSGlobalObject::kSize; | 687 switch (instance_type) { |
| 689 } else { | 688 case JavaScriptObject: |
| 690 instance_size += JSObject::kHeaderSize; | 689 type = JS_OBJECT_TYPE; |
| 690 instance_size += JSObject::kHeaderSize; |
| 691 break; |
| 692 case InnerGlobalObject: |
| 693 type = JS_GLOBAL_OBJECT_TYPE; |
| 694 instance_size += JSGlobalObject::kSize; |
| 695 break; |
| 696 case OuterGlobalObject: |
| 697 type = JS_GLOBAL_PROXY_TYPE; |
| 698 instance_size += JSGlobalProxy::kSize; |
| 699 break; |
| 700 default: |
| 701 ASSERT(false); |
| 702 break; |
| 691 } | 703 } |
| 692 | 704 |
| 693 InstanceType type = is_global ? JS_GLOBAL_OBJECT_TYPE : JS_OBJECT_TYPE; | |
| 694 | |
| 695 Handle<JSFunction> result = | 705 Handle<JSFunction> result = |
| 696 Factory::NewFunction(Factory::empty_symbol(), type, instance_size, | 706 Factory::NewFunction(Factory::empty_symbol(), type, instance_size, |
| 697 code, true); | 707 code, true); |
| 698 // Set class name. | 708 // Set class name. |
| 699 Handle<Object> class_name = Handle<Object>(obj->class_name()); | 709 Handle<Object> class_name = Handle<Object>(obj->class_name()); |
| 700 if (class_name->IsString()) { | 710 if (class_name->IsString()) { |
| 701 result->shared()->set_instance_class_name(*class_name); | 711 result->shared()->set_instance_class_name(*class_name); |
| 702 result->shared()->set_name(*class_name); | 712 result->shared()->set_name(*class_name); |
| 703 } | 713 } |
| 704 | 714 |
| 705 Handle<Map> map = Handle<Map>(result->initial_map()); | 715 Handle<Map> map = Handle<Map>(result->initial_map()); |
| 706 | 716 |
| 707 // Mark as undetectable if needed. | 717 // Mark as undetectable if needed. |
| 708 if (obj->undetectable()) { | 718 if (obj->undetectable()) { |
| 709 map->set_is_undetectable(); | 719 map->set_is_undetectable(); |
| 710 } | 720 } |
| 711 | 721 |
| 712 // Mark as hidden for the __proto__ accessor if needed. | 722 // Mark as hidden for the __proto__ accessor if needed. |
| 713 if (obj->hidden_prototype()) { | 723 if (obj->hidden_prototype()) { |
| 714 map->set_is_hidden_prototype(); | 724 map->set_is_hidden_prototype(); |
| 715 } | 725 } |
| 716 | 726 |
| 717 // Mark as needs_access_check if needed. | 727 // Mark as needs_access_check if needed. |
| 718 if (obj->needs_access_check()) { | 728 if (obj->needs_access_check()) { |
| 719 map->set_needs_access_check(); | 729 map->set_is_access_check_needed(); |
| 720 } | 730 } |
| 721 | 731 |
| 722 // Set interceptor information in the map. | 732 // Set interceptor information in the map. |
| 723 if (!obj->named_property_handler()->IsUndefined()) { | 733 if (!obj->named_property_handler()->IsUndefined()) { |
| 724 map->set_has_named_interceptor(); | 734 map->set_has_named_interceptor(); |
| 725 } | 735 } |
| 726 if (!obj->indexed_property_handler()->IsUndefined()) { | 736 if (!obj->indexed_property_handler()->IsUndefined()) { |
| 727 map->set_has_indexed_interceptor(); | 737 map->set_has_indexed_interceptor(); |
| 728 } | 738 } |
| 729 | 739 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 Execution::ConfigureInstance(instance, | 816 Execution::ConfigureInstance(instance, |
| 807 instance_template, | 817 instance_template, |
| 808 pending_exception); | 818 pending_exception); |
| 809 } else { | 819 } else { |
| 810 *pending_exception = false; | 820 *pending_exception = false; |
| 811 } | 821 } |
| 812 } | 822 } |
| 813 | 823 |
| 814 | 824 |
| 815 } } // namespace v8::internal | 825 } } // namespace v8::internal |
| OLD | NEW |