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/ia32/stub-cache-ia32.cc

Issue 657081: Fix uninitialized memory read in CallOptimization. (Closed)
Patch Set: Created 10 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 } 472 }
473 473
474 private: 474 private:
475 Register name_; 475 Register name_;
476 }; 476 };
477 477
478 478
479 // Holds information about possible function call optimizations. 479 // Holds information about possible function call optimizations.
480 class CallOptimization BASE_EMBEDDED { 480 class CallOptimization BASE_EMBEDDED {
481 public: 481 public:
482 explicit CallOptimization(LookupResult* lookup) 482 explicit CallOptimization(LookupResult* lookup) {
483 : constant_function_(NULL), 483 if (!lookup->IsProperty() || !lookup->IsCacheable() ||
484 is_simple_api_call_(false), 484 lookup->type() != CONSTANT_FUNCTION) {
485 expected_receiver_type_(NULL), 485 Initialize(NULL);
486 api_call_info_(NULL) { 486 } else {
487 if (!lookup->IsProperty() || !lookup->IsCacheable()) return; 487 // We only optimize constant function calls.
488 488 Initialize(lookup->GetConstantFunction());
489 // We only optimize constant function calls. 489 }
490 if (lookup->type() != CONSTANT_FUNCTION) return;
491
492 Initialize(lookup->GetConstantFunction());
493 } 490 }
494 491
495 explicit CallOptimization(JSFunction* function) { 492 explicit CallOptimization(JSFunction* function) {
496 Initialize(function); 493 Initialize(function);
497 } 494 }
498 495
499 bool is_constant_call() const { 496 bool is_constant_call() const {
500 return constant_function_ != NULL; 497 return constant_function_ != NULL;
501 } 498 }
502 499
(...skipping 27 matching lines...) Expand all
530 if (object->IsInstanceOf(expected_receiver_type_)) return depth; 527 if (object->IsInstanceOf(expected_receiver_type_)) return depth;
531 object = JSObject::cast(object->GetPrototype()); 528 object = JSObject::cast(object->GetPrototype());
532 ++depth; 529 ++depth;
533 } 530 }
534 if (holder->IsInstanceOf(expected_receiver_type_)) return depth; 531 if (holder->IsInstanceOf(expected_receiver_type_)) return depth;
535 return kInvalidProtoDepth; 532 return kInvalidProtoDepth;
536 } 533 }
537 534
538 private: 535 private:
539 void Initialize(JSFunction* function) { 536 void Initialize(JSFunction* function) {
540 if (!function->is_compiled()) return; 537 constant_function_ = NULL;
538 is_simple_api_call_ = false;
539 expected_receiver_type_ = NULL;
540 api_call_info_ = NULL;
541
542 if (function == NULL || !function->is_compiled()) return;
541 543
542 constant_function_ = function; 544 constant_function_ = function;
543 is_simple_api_call_ = false;
544
545 AnalyzePossibleApiFunction(function); 545 AnalyzePossibleApiFunction(function);
546 } 546 }
547 547
548 // Determines whether the given function can be called using the 548 // Determines whether the given function can be called using the
549 // fast api call builtin. 549 // fast api call builtin.
550 void AnalyzePossibleApiFunction(JSFunction* function) { 550 void AnalyzePossibleApiFunction(JSFunction* function) {
551 SharedFunctionInfo* sfi = function->shared(); 551 SharedFunctionInfo* sfi = function->shared();
552 if (sfi->function_data()->IsUndefined()) return; 552 if (sfi->function_data()->IsUndefined()) return;
553 FunctionTemplateInfo* info = 553 FunctionTemplateInfo* info =
554 FunctionTemplateInfo::cast(sfi->function_data()); 554 FunctionTemplateInfo::cast(sfi->function_data());
(...skipping 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after
2202 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); 2202 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET);
2203 2203
2204 // Return the generated code. 2204 // Return the generated code.
2205 return GetCode(); 2205 return GetCode();
2206 } 2206 }
2207 2207
2208 2208
2209 #undef __ 2209 #undef __
2210 2210
2211 } } // namespace v8::internal 2211 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698