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

Side by Side Diff: src/x64/codegen-x64.cc

Issue 1563005: Introduce fast native caches and use it in String.search. (Closed)
Patch Set: Last round :) 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
« no previous file with comments | « src/x64/codegen-x64.h ('k') | test/mjsunit/fuzz-natives.js » ('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 4241 matching lines...) Expand 10 before | Expand all | Expand 10 after
4252 __ bind(&slowcase); 4252 __ bind(&slowcase);
4253 __ CallRuntime(Runtime::kRegExpConstructResult, 3); 4253 __ CallRuntime(Runtime::kRegExpConstructResult, 3);
4254 4254
4255 __ bind(&done); 4255 __ bind(&done);
4256 } 4256 }
4257 frame_->Forget(3); 4257 frame_->Forget(3);
4258 frame_->Push(rax); 4258 frame_->Push(rax);
4259 } 4259 }
4260 4260
4261 4261
4262 class DeferredSearchCache: public DeferredCode {
4263 public:
4264 DeferredSearchCache(Register dst, Register cache, Register key)
4265 : dst_(dst), cache_(cache), key_(key) {
4266 set_comment("[ DeferredSearchCache");
4267 }
4268
4269 virtual void Generate();
4270
4271 private:
4272 Register dst_, cache_, key_;
4273 };
4274
4275
4276 void DeferredSearchCache::Generate() {
4277 __ push(cache_);
4278 __ push(key_);
4279 __ CallRuntime(Runtime::kGetFromCache, 2);
4280 if (!dst_.is(rax)) {
4281 __ movq(dst_, rax);
4282 }
4283 }
4284
4285
4286 void CodeGenerator::GenerateGetFromCache(ZoneList<Expression*>* args) {
4287 ASSERT_EQ(2, args->length());
4288
4289 ASSERT_NE(NULL, args->at(0)->AsLiteral());
4290 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value();
4291
4292 Handle<FixedArray> jsfunction_result_caches(
4293 Top::global_context()->jsfunction_result_caches());
4294 if (jsfunction_result_caches->length() <= cache_id) {
4295 __ Abort("Attempt to use undefined cache.");
4296 frame_->Push(Factory::undefined_value());
4297 return;
4298 }
4299 Handle<FixedArray> cache_obj(
4300 FixedArray::cast(jsfunction_result_caches->get(cache_id)));
4301
4302 Load(args->at(1));
4303 Result key = frame_->Pop();
4304 key.ToRegister();
4305
4306 Result cache = allocator()->Allocate();
4307 __ movq(cache.reg(), cache_obj, RelocInfo::EMBEDDED_OBJECT);
4308
4309 Result tmp = allocator()->Allocate();
4310
4311 DeferredSearchCache* deferred = new DeferredSearchCache(tmp.reg(),
4312 cache.reg(),
4313 key.reg());
4314
4315 const int kFingerOffset =
4316 FixedArray::OffsetOfElementAt(JSFunctionResultCache::kFingerIndex);
4317 // tmp.reg() now holds finger offset as a smi.
4318 ASSERT(kSmiTag == 0 && kSmiTagSize == 1);
4319 __ movq(tmp.reg(), FieldOperand(cache.reg(), kFingerOffset));
4320 SmiIndex index =
4321 masm()->SmiToIndex(kScratchRegister, tmp.reg(), kPointerSizeLog2);
4322 __ cmpq(key.reg(), FieldOperand(cache.reg(),
4323 index.reg,
4324 index.scale,
4325 FixedArray::kHeaderSize));
4326 deferred->Branch(not_equal);
4327
4328 __ movq(tmp.reg(), FieldOperand(cache.reg(),
4329 index.reg,
4330 index.scale,
4331 kPointerSize + FixedArray::kHeaderSize));
4332
4333 deferred->BindExit();
4334 frame_->Push(&tmp);
4335 }
4336
4337
4262 void CodeGenerator::GenerateNumberToString(ZoneList<Expression*>* args) { 4338 void CodeGenerator::GenerateNumberToString(ZoneList<Expression*>* args) {
4263 ASSERT_EQ(args->length(), 1); 4339 ASSERT_EQ(args->length(), 1);
4264 4340
4265 // Load the argument on the stack and jump to the runtime. 4341 // Load the argument on the stack and jump to the runtime.
4266 Load(args->at(0)); 4342 Load(args->at(0));
4267 4343
4268 NumberToStringStub stub; 4344 NumberToStringStub stub;
4269 Result result = frame_->CallStub(&stub, 1); 4345 Result result = frame_->CallStub(&stub, 1);
4270 frame_->Push(&result); 4346 frame_->Push(&result);
4271 } 4347 }
(...skipping 6080 matching lines...) Expand 10 before | Expand all | Expand 10 after
10352 // Call the function from C++. 10428 // Call the function from C++.
10353 return FUNCTION_CAST<ModuloFunction>(buffer); 10429 return FUNCTION_CAST<ModuloFunction>(buffer);
10354 } 10430 }
10355 10431
10356 #endif 10432 #endif
10357 10433
10358 10434
10359 #undef __ 10435 #undef __
10360 10436
10361 } } // namespace v8::internal 10437 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/x64/codegen-x64.h ('k') | test/mjsunit/fuzz-natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698