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

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

Issue 1650011: Port inlining of type checks in call ICs for API functions to x64 and arm (is... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 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/stub-cache.h ('k') | src/x64/macro-assembler-x64.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 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 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 Object* result = GetCodeWithFlags(flags, "ConstructStub"); 1157 Object* result = GetCodeWithFlags(flags, "ConstructStub");
1158 if (!result->IsFailure()) { 1158 if (!result->IsFailure()) {
1159 Code* code = Code::cast(result); 1159 Code* code = Code::cast(result);
1160 USE(code); 1160 USE(code);
1161 PROFILE(CodeCreateEvent(Logger::STUB_TAG, code, "ConstructStub")); 1161 PROFILE(CodeCreateEvent(Logger::STUB_TAG, code, "ConstructStub"));
1162 } 1162 }
1163 return result; 1163 return result;
1164 } 1164 }
1165 1165
1166 1166
1167 CallOptimization::CallOptimization(LookupResult* lookup) {
1168 if (!lookup->IsProperty() || !lookup->IsCacheable() ||
1169 lookup->type() != CONSTANT_FUNCTION) {
1170 Initialize(NULL);
1171 } else {
1172 // We only optimize constant function calls.
1173 Initialize(lookup->GetConstantFunction());
1174 }
1175 }
1176
1177 CallOptimization::CallOptimization(JSFunction* function) {
1178 Initialize(function);
1179 }
1180
1181
1182 int CallOptimization::GetPrototypeDepthOfExpectedType(JSObject* object,
1183 JSObject* holder) const {
1184 ASSERT(is_simple_api_call_);
1185 if (expected_receiver_type_ == NULL) return 0;
1186 int depth = 0;
1187 while (object != holder) {
1188 if (object->IsInstanceOf(expected_receiver_type_)) return depth;
1189 object = JSObject::cast(object->GetPrototype());
1190 ++depth;
1191 }
1192 if (holder->IsInstanceOf(expected_receiver_type_)) return depth;
1193 return kInvalidProtoDepth;
1194 }
1195
1196
1197 void CallOptimization::Initialize(JSFunction* function) {
1198 constant_function_ = NULL;
1199 is_simple_api_call_ = false;
1200 expected_receiver_type_ = NULL;
1201 api_call_info_ = NULL;
1202
1203 if (function == NULL || !function->is_compiled()) return;
1204
1205 constant_function_ = function;
1206 AnalyzePossibleApiFunction(function);
1207 }
1208
1209
1210 void CallOptimization::AnalyzePossibleApiFunction(JSFunction* function) {
1211 SharedFunctionInfo* sfi = function->shared();
1212 if (!sfi->IsApiFunction()) return;
1213 FunctionTemplateInfo* info = sfi->get_api_func_data();
1214
1215 // Require a C++ callback.
1216 if (info->call_code()->IsUndefined()) return;
1217 api_call_info_ = CallHandlerInfo::cast(info->call_code());
1218
1219 // Accept signatures that either have no restrictions at all or
1220 // only have restrictions on the receiver.
1221 if (!info->signature()->IsUndefined()) {
1222 SignatureInfo* signature = SignatureInfo::cast(info->signature());
1223 if (!signature->args()->IsUndefined()) return;
1224 if (!signature->receiver()->IsUndefined()) {
1225 expected_receiver_type_ =
1226 FunctionTemplateInfo::cast(signature->receiver());
1227 }
1228 }
1229
1230 is_simple_api_call_ = true;
1231 }
1232
1233
1167 } } // namespace v8::internal 1234 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/stub-cache.h ('k') | src/x64/macro-assembler-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698