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

Side by Side Diff: src/ia32/stub-cache-ia32.cc

Issue 661020: Version 2.1.2.1... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
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 | Annotate | Revision Log
« no previous file with comments | « src/ast.h ('k') | src/version.cc » ('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 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 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 JSFunction* function, 1216 JSFunction* function,
1217 String* name, 1217 String* name,
1218 CheckType check) { 1218 CheckType check) {
1219 // ----------- S t a t e ------------- 1219 // ----------- S t a t e -------------
1220 // -- ecx : name 1220 // -- ecx : name
1221 // -- esp[0] : return address 1221 // -- esp[0] : return address
1222 // -- esp[(argc - n) * 4] : arg[n] (zero-based) 1222 // -- esp[(argc - n) * 4] : arg[n] (zero-based)
1223 // -- ... 1223 // -- ...
1224 // -- esp[(argc + 1) * 4] : receiver 1224 // -- esp[(argc + 1) * 4] : receiver
1225 // ----------------------------------- 1225 // -----------------------------------
1226 Label miss; 1226 Label miss_in_smi_check;
1227 1227
1228 // Get the receiver from the stack. 1228 // Get the receiver from the stack.
1229 const int argc = arguments().immediate(); 1229 const int argc = arguments().immediate();
1230 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); 1230 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize));
1231 1231
1232 // Check that the receiver isn't a smi. 1232 // Check that the receiver isn't a smi.
1233 if (check != NUMBER_CHECK) { 1233 if (check != NUMBER_CHECK) {
1234 __ test(edx, Immediate(kSmiTagMask)); 1234 __ test(edx, Immediate(kSmiTagMask));
1235 __ j(zero, &miss, not_taken); 1235 __ j(zero, &miss_in_smi_check, not_taken);
1236 } 1236 }
1237 1237
1238 // Make sure that it's okay not to patch the on stack receiver 1238 // Make sure that it's okay not to patch the on stack receiver
1239 // unless we're doing a receiver map check. 1239 // unless we're doing a receiver map check.
1240 ASSERT(!object->IsGlobalObject() || check == RECEIVER_MAP_CHECK); 1240 ASSERT(!object->IsGlobalObject() || check == RECEIVER_MAP_CHECK);
1241 1241
1242 CallOptimization optimization(function); 1242 CallOptimization optimization(function);
1243 int depth = kInvalidProtoDepth; 1243 int depth = kInvalidProtoDepth;
1244 Label miss;
1244 1245
1245 switch (check) { 1246 switch (check) {
1246 case RECEIVER_MAP_CHECK: 1247 case RECEIVER_MAP_CHECK:
1247 __ IncrementCounter(&Counters::call_const, 1); 1248 __ IncrementCounter(&Counters::call_const, 1);
1248 1249
1249 if (optimization.is_simple_api_call() && !object->IsGlobalObject()) { 1250 if (optimization.is_simple_api_call() && !object->IsGlobalObject()) {
1250 depth = optimization.GetPrototypeDepthOfExpectedType( 1251 depth = optimization.GetPrototypeDepthOfExpectedType(
1251 JSObject::cast(object), holder); 1252 JSObject::cast(object), holder);
1252 } 1253 }
1253 1254
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1352 GenerateFastApiCall(masm(), optimization, argc); 1353 GenerateFastApiCall(masm(), optimization, argc);
1353 } else { 1354 } else {
1354 __ InvokeFunction(function, arguments(), JUMP_FUNCTION); 1355 __ InvokeFunction(function, arguments(), JUMP_FUNCTION);
1355 } 1356 }
1356 1357
1357 // Handle call cache miss. 1358 // Handle call cache miss.
1358 __ bind(&miss); 1359 __ bind(&miss);
1359 if (depth != kInvalidProtoDepth) { 1360 if (depth != kInvalidProtoDepth) {
1360 FreeSpaceForFastApiCall(masm(), eax); 1361 FreeSpaceForFastApiCall(masm(), eax);
1361 } 1362 }
1363 __ bind(&miss_in_smi_check);
1362 Handle<Code> ic = ComputeCallMiss(arguments().immediate()); 1364 Handle<Code> ic = ComputeCallMiss(arguments().immediate());
1363 __ jmp(ic, RelocInfo::CODE_TARGET); 1365 __ jmp(ic, RelocInfo::CODE_TARGET);
1364 1366
1365 // Return the generated code. 1367 // Return the generated code.
1366 String* function_name = NULL; 1368 String* function_name = NULL;
1367 if (function->shared()->name()->IsString()) { 1369 if (function->shared()->name()->IsString()) {
1368 function_name = String::cast(function->shared()->name()); 1370 function_name = String::cast(function->shared()->name());
1369 } 1371 }
1370 return GetCode(CONSTANT_FUNCTION, function_name); 1372 return GetCode(CONSTANT_FUNCTION, function_name);
1371 } 1373 }
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
2202 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); 2204 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET);
2203 2205
2204 // Return the generated code. 2206 // Return the generated code.
2205 return GetCode(); 2207 return GetCode();
2206 } 2208 }
2207 2209
2208 2210
2209 #undef __ 2211 #undef __
2210 2212
2211 } } // namespace v8::internal 2213 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.h ('k') | src/version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698