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

Side by Side Diff: src/ic.cc

Issue 542087: Ensure correct boxing of values when calling functions on them... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 11 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-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 const int argc = this->target()->arguments_count(); 371 const int argc = this->target()->arguments_count();
372 StackFrameLocator locator; 372 StackFrameLocator locator;
373 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); 373 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0);
374 int index = frame->ComputeExpressionsCount() - (argc + 1); 374 int index = frame->ComputeExpressionsCount() - (argc + 1);
375 frame->SetExpression(index, *target); 375 frame->SetExpression(index, *target);
376 } 376 }
377 377
378 return *delegate; 378 return *delegate;
379 } 379 }
380 380
381 void CallIC::ReceiverToObject(Object* object) {
382 HandleScope scope;
383 Handle<Object> receiver(object);
384
385 // Change the receiver to the result of calling ToObject on it.
386 const int argc = this->target()->arguments_count();
387 StackFrameLocator locator;
388 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0);
389 int index = frame->ComputeExpressionsCount() - (argc + 1);
390 frame->SetExpression(index, object->ToObject());
391 }
392
381 393
382 Object* CallIC::LoadFunction(State state, 394 Object* CallIC::LoadFunction(State state,
383 Handle<Object> object, 395 Handle<Object> object,
384 Handle<String> name) { 396 Handle<String> name) {
385 // If the object is undefined or null it's illegal to try to get any 397 // If the object is undefined or null it's illegal to try to get any
386 // of its properties; throw a TypeError in that case. 398 // of its properties; throw a TypeError in that case.
387 if (object->IsUndefined() || object->IsNull()) { 399 if (object->IsUndefined() || object->IsNull()) {
388 return TypeError("non_object_property_call", object, name); 400 return TypeError("non_object_property_call", object, name);
389 } 401 }
390 402
403 if (object->IsString() || object->IsNumber() || object->IsBoolean()) {
404 ReceiverToObject(*object);
405 }
406
391 // Check if the name is trivially convertible to an index and get 407 // Check if the name is trivially convertible to an index and get
392 // the element if so. 408 // the element if so.
393 uint32_t index; 409 uint32_t index;
394 if (name->AsArrayIndex(&index)) { 410 if (name->AsArrayIndex(&index)) {
395 Object* result = object->GetElement(index); 411 Object* result = object->GetElement(index);
396 if (result->IsJSFunction()) return result; 412 if (result->IsJSFunction()) return result;
397 413
398 // Try to find a suitable function delegate for the object at hand. 414 // Try to find a suitable function delegate for the object at hand.
399 result = TryCallAsFunction(result); 415 result = TryCallAsFunction(result);
400 if (result->IsJSFunction()) return result; 416 if (result->IsJSFunction()) return result;
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
1417 #undef ADDR 1433 #undef ADDR
1418 }; 1434 };
1419 1435
1420 1436
1421 Address IC::AddressFromUtilityId(IC::UtilityId id) { 1437 Address IC::AddressFromUtilityId(IC::UtilityId id) {
1422 return IC_utilities[id]; 1438 return IC_utilities[id];
1423 } 1439 }
1424 1440
1425 1441
1426 } } // namespace v8::internal 1442 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ic.h ('k') | src/x64/codegen-x64.h » ('j') | test/mjsunit/value-wrapper.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698