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

Side by Side Diff: src/runtime.cc

Issue 6691054: [Arguments] Merge (7442,7496] from bleeding_edge. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/arguments
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
« no previous file with comments | « src/platform-win32.cc ('k') | src/scopes.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7151 matching lines...) Expand 10 before | Expand all | Expand 10 after
7162 // directly to properties. 7162 // directly to properties.
7163 pretenure = pretenure || (context->global_context() == *context); 7163 pretenure = pretenure || (context->global_context() == *context);
7164 PretenureFlag pretenure_flag = pretenure ? TENURED : NOT_TENURED; 7164 PretenureFlag pretenure_flag = pretenure ? TENURED : NOT_TENURED;
7165 Handle<JSFunction> result = 7165 Handle<JSFunction> result =
7166 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, 7166 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared,
7167 context, 7167 context,
7168 pretenure_flag); 7168 pretenure_flag);
7169 return *result; 7169 return *result;
7170 } 7170 }
7171 7171
7172
7173 static SmartPointer<Object**> GetNonBoundArguments(int bound_argc,
7174 int* total_argc) {
7175 // Find frame containing arguments passed to the caller.
7176 JavaScriptFrameIterator it;
7177 JavaScriptFrame* frame = it.frame();
7178 List<JSFunction*> functions(2);
7179 frame->GetFunctions(&functions);
7180 if (functions.length() > 1) {
7181 int inlined_frame_index = functions.length() - 1;
7182 JSFunction* inlined_function = functions[inlined_frame_index];
7183 int args_count = inlined_function->shared()->formal_parameter_count();
7184 ScopedVector<SlotRef> args_slots(args_count);
7185 SlotRef::ComputeSlotMappingForArguments(frame,
7186 inlined_frame_index,
7187 &args_slots);
7188
7189 *total_argc = bound_argc + args_count;
7190 SmartPointer<Object**> param_data(NewArray<Object**>(*total_argc));
7191 for (int i = 0; i < args_count; i++) {
7192 Handle<Object> val = args_slots[i].GetValue();
7193 param_data[bound_argc + i] = val.location();
7194 }
7195 return param_data;
7196 } else {
7197 it.AdvanceToArgumentsFrame();
7198 frame = it.frame();
7199 int args_count = frame->ComputeParametersCount();
7200
7201 *total_argc = bound_argc + args_count;
7202 SmartPointer<Object**> param_data(NewArray<Object**>(*total_argc));
7203 for (int i = 0; i < args_count; i++) {
7204 Handle<Object> val = Handle<Object>(frame->GetParameter(i));
7205 param_data[bound_argc + i] = val.location();
7206 }
7207 return param_data;
7208 }
7209 }
7210
7211
7172 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewObjectFromBound) { 7212 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewObjectFromBound) {
7173 HandleScope scope(isolate); 7213 HandleScope scope(isolate);
7174 ASSERT(args.length() == 2); 7214 ASSERT(args.length() == 2);
7175 // First argument is a function to use as a constructor. 7215 // First argument is a function to use as a constructor.
7176 CONVERT_ARG_CHECKED(JSFunction, function, 0); 7216 CONVERT_ARG_CHECKED(JSFunction, function, 0);
7177 7217
7178 // Second argument is either null or an array of bound arguments. 7218 // Second argument is either null or an array of bound arguments.
7179 FixedArray* bound_args = NULL; 7219 Handle<FixedArray> bound_args;
7180 int bound_argc = 0; 7220 int bound_argc = 0;
7181 if (!args[1]->IsNull()) { 7221 if (!args[1]->IsNull()) {
7182 CONVERT_ARG_CHECKED(JSArray, params, 1); 7222 CONVERT_ARG_CHECKED(JSArray, params, 1);
7183 RUNTIME_ASSERT(params->HasFastElements()); 7223 RUNTIME_ASSERT(params->HasFastElements());
7184 bound_args = FixedArray::cast(params->elements()); 7224 bound_args = Handle<FixedArray>(FixedArray::cast(params->elements()));
7185 bound_argc = Smi::cast(params->length())->value(); 7225 bound_argc = Smi::cast(params->length())->value();
7186 } 7226 }
7187 7227
7188 // Find frame containing arguments passed to the caller. 7228 int total_argc = 0;
7189 JavaScriptFrameIterator it; 7229 SmartPointer<Object**> param_data =
7190 JavaScriptFrame* frame = it.frame(); 7230 GetNonBoundArguments(bound_argc, &total_argc);
7191 ASSERT(!frame->is_optimized());
7192 it.AdvanceToArgumentsFrame();
7193 frame = it.frame();
7194 int argc = frame->ComputeParametersCount();
7195
7196 // Prepend bound arguments to caller's arguments.
7197 int total_argc = bound_argc + argc;
7198 SmartPointer<Object**> param_data(NewArray<Object**>(total_argc));
7199 for (int i = 0; i < bound_argc; i++) { 7231 for (int i = 0; i < bound_argc; i++) {
7200 Handle<Object> val = Handle<Object>(bound_args->get(i)); 7232 Handle<Object> val = Handle<Object>(bound_args->get(i));
7201 param_data[i] = val.location(); 7233 param_data[i] = val.location();
7202 } 7234 }
7203 for (int i = 0; i < argc; i++) {
7204 Handle<Object> val = Handle<Object>(frame->GetParameter(i));
7205 param_data[bound_argc + i] = val.location();
7206 }
7207 7235
7208 bool exception = false; 7236 bool exception = false;
7209 Handle<Object> result = 7237 Handle<Object> result =
7210 Execution::New(function, total_argc, *param_data, &exception); 7238 Execution::New(function, total_argc, *param_data, &exception);
7211 if (exception) { 7239 if (exception) {
7212 return Failure::Exception(); 7240 return Failure::Exception();
7213 } 7241 }
7214 7242
7215 ASSERT(!result.is_null()); 7243 ASSERT(!result.is_null());
7216 return *result; 7244 return *result;
(...skipping 4769 matching lines...) Expand 10 before | Expand all | Expand 10 after
11986 } else { 12014 } else {
11987 // Handle last resort GC and make sure to allow future allocations 12015 // Handle last resort GC and make sure to allow future allocations
11988 // to grow the heap without causing GCs (if possible). 12016 // to grow the heap without causing GCs (if possible).
11989 isolate->counters()->gc_last_resort_from_js()->Increment(); 12017 isolate->counters()->gc_last_resort_from_js()->Increment();
11990 isolate->heap()->CollectAllGarbage(false); 12018 isolate->heap()->CollectAllGarbage(false);
11991 } 12019 }
11992 } 12020 }
11993 12021
11994 12022
11995 } } // namespace v8::internal 12023 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-win32.cc ('k') | src/scopes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698