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

Side by Side Diff: src/runtime.cc

Issue 6262: Improve performance of arguments object allocation by taking... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 2 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
OLDNEW
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 2685 matching lines...) Expand 10 before | Expand all | Expand 10 after
2696 2696
2697 static Object* Runtime_Math_tan(Arguments args) { 2697 static Object* Runtime_Math_tan(Arguments args) {
2698 NoHandleAllocation ha; 2698 NoHandleAllocation ha;
2699 ASSERT(args.length() == 1); 2699 ASSERT(args.length() == 1);
2700 2700
2701 CONVERT_DOUBLE_CHECKED(x, args[0]); 2701 CONVERT_DOUBLE_CHECKED(x, args[0]);
2702 return Heap::AllocateHeapNumber(tan(x)); 2702 return Heap::AllocateHeapNumber(tan(x));
2703 } 2703 }
2704 2704
2705 2705
2706 // The NewArguments function is only used when constructing the
2707 // arguments array when calling non-functions from JavaScript in
2708 // runtime.js:CALL_NON_FUNCTION.
2706 static Object* Runtime_NewArguments(Arguments args) { 2709 static Object* Runtime_NewArguments(Arguments args) {
2707 NoHandleAllocation ha; 2710 NoHandleAllocation ha;
2708 ASSERT(args.length() == 1); 2711 ASSERT(args.length() == 1);
2709 2712
2710 // ECMA-262, 3rd., 10.1.8, p.39 2713 // ECMA-262, 3rd., 10.1.8, p.39
2711 CONVERT_CHECKED(JSFunction, callee, args[0]); 2714 CONVERT_CHECKED(JSFunction, callee, args[0]);
2712 2715
2713 // Compute the frame holding the arguments. 2716 // Compute the frame holding the arguments.
2714 JavaScriptFrameIterator it; 2717 JavaScriptFrameIterator it;
2715 it.AdvanceToArgumentsFrame(); 2718 it.AdvanceToArgumentsFrame();
2716 JavaScriptFrame* frame = it.frame(); 2719 JavaScriptFrame* frame = it.frame();
2717 2720
2718 const int length = frame->GetProvidedParametersCount(); 2721 const int length = frame->GetProvidedParametersCount();
2719 Object* result = Heap::AllocateArgumentsObject(callee, length); 2722 Object* result = Heap::AllocateArgumentsObject(callee, length);
2720 if (result->IsFailure()) return result; 2723 if (result->IsFailure()) return result;
2721 FixedArray* array = FixedArray::cast(JSObject::cast(result)->elements()); 2724 FixedArray* array = FixedArray::cast(JSObject::cast(result)->elements());
2722 ASSERT(array->length() == length); 2725 ASSERT(array->length() == length);
2723 for (int i = 0; i < length; i++) { 2726 for (int i = 0; i < length; i++) {
2724 array->set(i, frame->GetParameter(i)); 2727 array->set(i, frame->GetParameter(i));
2725 } 2728 }
2726 return result; 2729 return result;
2727 } 2730 }
2728 2731
2729 2732
2733 static Object* Runtime_NewArgumentsFast(Arguments args) {
2734 NoHandleAllocation ha;
2735 ASSERT(args.length() == 3);
2736
2737 JSFunction* callee = JSFunction::cast(args[0]);
2738 Object** parameters = reinterpret_cast<Object**>(args[1]);
2739 const int length = Smi::cast(args[2])->value();
2740
2741 Object* result = Heap::AllocateArgumentsObject(callee, length);
2742 if (result->IsFailure()) return result;
2743 FixedArray* array = FixedArray::cast(JSObject::cast(result)->elements());
2744 ASSERT(array->length() == length);
2745 FixedArray::WriteBarrierMode mode = array->GetWriteBarrierMode();
2746 for (int i = 0; i < length; i++) {
2747 array->set(i, *--parameters, mode);
2748 }
2749 return result;
2750 }
2751
2752
2730 static Object* Runtime_NewClosure(Arguments args) { 2753 static Object* Runtime_NewClosure(Arguments args) {
2731 HandleScope scope; 2754 HandleScope scope;
2732 ASSERT(args.length() == 2); 2755 ASSERT(args.length() == 2);
2733 CONVERT_ARG_CHECKED(JSFunction, boilerplate, 0); 2756 CONVERT_ARG_CHECKED(JSFunction, boilerplate, 0);
2734 CONVERT_ARG_CHECKED(Context, context, 1); 2757 CONVERT_ARG_CHECKED(Context, context, 1);
2735 2758
2736 Handle<JSFunction> result = 2759 Handle<JSFunction> result =
2737 Factory::NewFunctionFromBoilerplate(boilerplate, context); 2760 Factory::NewFunctionFromBoilerplate(boilerplate, context);
2738 return *result; 2761 return *result;
2739 } 2762 }
(...skipping 2287 matching lines...) Expand 10 before | Expand all | Expand 10 after
5027 5050
5028 void Runtime::PerformGC(Object* result) { 5051 void Runtime::PerformGC(Object* result) {
5029 Failure* failure = Failure::cast(result); 5052 Failure* failure = Failure::cast(result);
5030 // Try to do a garbage collection; ignore it if it fails. The C 5053 // Try to do a garbage collection; ignore it if it fails. The C
5031 // entry stub will throw an out-of-memory exception in that case. 5054 // entry stub will throw an out-of-memory exception in that case.
5032 Heap::CollectGarbage(failure->requested(), failure->allocation_space()); 5055 Heap::CollectGarbage(failure->requested(), failure->allocation_space());
5033 } 5056 }
5034 5057
5035 5058
5036 } } // namespace v8::internal 5059 } } // namespace v8::internal
OLDNEW
« src/codegen-arm.cc ('K') | « src/runtime.h ('k') | test/mjsunit/fuzz-natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698