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

Side by Side Diff: src/runtime.cc

Issue 6740023: Fix SlotRef::SlotAddress for parameters indices. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 8 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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 7048 matching lines...) Expand 10 before | Expand all | Expand 10 after
7059 // directly to properties. 7059 // directly to properties.
7060 pretenure = pretenure || (context->global_context() == *context); 7060 pretenure = pretenure || (context->global_context() == *context);
7061 PretenureFlag pretenure_flag = pretenure ? TENURED : NOT_TENURED; 7061 PretenureFlag pretenure_flag = pretenure ? TENURED : NOT_TENURED;
7062 Handle<JSFunction> result = 7062 Handle<JSFunction> result =
7063 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, 7063 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared,
7064 context, 7064 context,
7065 pretenure_flag); 7065 pretenure_flag);
7066 return *result; 7066 return *result;
7067 } 7067 }
7068 7068
7069
7070 static SmartPointer<Object**> GetNonBoundArguments(int bound_argc,
7071 int* total_argc) {
7072 // Find frame containing arguments passed to the caller.
7073 JavaScriptFrameIterator it;
7074 JavaScriptFrame* frame = it.frame();
7075 List<JSFunction*> functions(2);
7076 frame->GetFunctions(&functions);
7077 if (functions.length() > 1) {
7078 int inlined_frame_index = functions.length() - 1;
7079 JSFunction* inlined_function = functions[inlined_frame_index];
7080 int args_count = inlined_function->shared()->formal_parameter_count();
7081 ScopedVector<SlotRef> args_slots(args_count);
7082 SlotRef::ComputeSlotMappingForArguments(frame,
7083 inlined_frame_index,
7084 &args_slots);
7085
7086 *total_argc = bound_argc + args_count;
7087 SmartPointer<Object**> param_data(NewArray<Object**>(*total_argc));
7088 for (int i = 0; i < args_count; i++) {
7089 Handle<Object> val = args_slots[i].GetValue();
7090 param_data[bound_argc + i] = val.location();
7091 }
7092 return param_data;
7093 } else {
7094 it.AdvanceToArgumentsFrame();
7095 frame = it.frame();
7096 int args_count = frame->ComputeParametersCount();
7097
7098 *total_argc = bound_argc + args_count;
7099 SmartPointer<Object**> param_data(NewArray<Object**>(*total_argc));
7100 for (int i = 0; i < args_count; i++) {
7101 Handle<Object> val = Handle<Object>(frame->GetParameter(i));
7102 param_data[bound_argc + i] = val.location();
7103 }
7104 return param_data;
7105 }
7106 }
7107
7108
7069 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewObjectFromBound) { 7109 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewObjectFromBound) {
7070 HandleScope scope(isolate); 7110 HandleScope scope(isolate);
7071 ASSERT(args.length() == 2); 7111 ASSERT(args.length() == 2);
7072 // First argument is a function to use as a constructor. 7112 // First argument is a function to use as a constructor.
7073 CONVERT_ARG_CHECKED(JSFunction, function, 0); 7113 CONVERT_ARG_CHECKED(JSFunction, function, 0);
7074 7114
7075 // Second argument is either null or an array of bound arguments. 7115 // Second argument is either null or an array of bound arguments.
7076 FixedArray* bound_args = NULL; 7116 Handle<FixedArray> bound_args;
7077 int bound_argc = 0; 7117 int bound_argc = 0;
7078 if (!args[1]->IsNull()) { 7118 if (!args[1]->IsNull()) {
7079 CONVERT_ARG_CHECKED(JSArray, params, 1); 7119 CONVERT_ARG_CHECKED(JSArray, params, 1);
7080 RUNTIME_ASSERT(params->HasFastElements()); 7120 RUNTIME_ASSERT(params->HasFastElements());
7081 bound_args = FixedArray::cast(params->elements()); 7121 bound_args = Handle<FixedArray>(FixedArray::cast(params->elements()));
7082 bound_argc = Smi::cast(params->length())->value(); 7122 bound_argc = Smi::cast(params->length())->value();
7083 } 7123 }
7084 7124
7085 // Find frame containing arguments passed to the caller. 7125 int total_argc = 0;
7086 JavaScriptFrameIterator it; 7126 SmartPointer<Object**> param_data =
7087 JavaScriptFrame* frame = it.frame(); 7127 GetNonBoundArguments(bound_argc, &total_argc);
7088 ASSERT(!frame->is_optimized());
7089 it.AdvanceToArgumentsFrame();
7090 frame = it.frame();
7091 int argc = frame->ComputeParametersCount();
7092
7093 // Prepend bound arguments to caller's arguments.
7094 int total_argc = bound_argc + argc;
7095 SmartPointer<Object**> param_data(NewArray<Object**>(total_argc));
7096 for (int i = 0; i < bound_argc; i++) { 7128 for (int i = 0; i < bound_argc; i++) {
7097 Handle<Object> val = Handle<Object>(bound_args->get(i)); 7129 Handle<Object> val = Handle<Object>(bound_args->get(i));
7098 param_data[i] = val.location(); 7130 param_data[i] = val.location();
7099 } 7131 }
7100 for (int i = 0; i < argc; i++) {
7101 Handle<Object> val = Handle<Object>(frame->GetParameter(i));
7102 param_data[bound_argc + i] = val.location();
7103 }
7104 7132
7105 bool exception = false; 7133 bool exception = false;
7106 Handle<Object> result = 7134 Handle<Object> result =
7107 Execution::New(function, total_argc, *param_data, &exception); 7135 Execution::New(function, total_argc, *param_data, &exception);
7108 if (exception) { 7136 if (exception) {
7109 return Failure::Exception(); 7137 return Failure::Exception();
7110 } 7138 }
7111 7139
7112 ASSERT(!result.is_null()); 7140 ASSERT(!result.is_null());
7113 return *result; 7141 return *result;
(...skipping 4796 matching lines...) Expand 10 before | Expand all | Expand 10 after
11910 } else { 11938 } else {
11911 // Handle last resort GC and make sure to allow future allocations 11939 // Handle last resort GC and make sure to allow future allocations
11912 // to grow the heap without causing GCs (if possible). 11940 // to grow the heap without causing GCs (if possible).
11913 isolate->counters()->gc_last_resort_from_js()->Increment(); 11941 isolate->counters()->gc_last_resort_from_js()->Increment();
11914 isolate->heap()->CollectAllGarbage(false); 11942 isolate->heap()->CollectAllGarbage(false);
11915 } 11943 }
11916 } 11944 }
11917 11945
11918 11946
11919 } } // namespace v8::internal 11947 } } // namespace v8::internal
OLDNEW
« src/deoptimizer.h ('K') | « src/hydrogen.cc ('k') | test/mjsunit/regress/regress-1229.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698