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

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

Issue 300037: Fast compiler support for regexp literals.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 2 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/ia32/fast-codegen-ia32.cc ('k') | 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 2009 the V8 project authors. All rights reserved. 1 // Copyright 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 ASSERT(slot != NULL); 215 ASSERT(slot != NULL);
216 if (expr->location().is_temporary()) { 216 if (expr->location().is_temporary()) {
217 __ push(Operand(rbp, SlotOffset(slot))); 217 __ push(Operand(rbp, SlotOffset(slot)));
218 } else { 218 } else {
219 ASSERT(expr->location().is_nowhere()); 219 ASSERT(expr->location().is_nowhere());
220 } 220 }
221 } 221 }
222 } 222 }
223 223
224 224
225 void FastCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
226 Comment cmnt(masm_, "[ RegExp Literal");
227 Label done;
228 // Registers will be used as follows:
229 // rdi = JS function.
230 // rbx = literals array.
231 // rax = regexp literal.
232 __ movq(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
233 __ movq(rbx, FieldOperand(rdi, JSFunction::kLiteralsOffset));
234 int literal_offset =
235 FixedArray::kHeaderSize + expr->literal_index() * kPointerSize;
236 __ movq(rax, FieldOperand(rbx, literal_offset));
237 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex);
238 __ j(not_equal, &done);
239 // Create regexp literal using runtime function
240 // Result will be in rax.
241 __ push(rbx);
242 __ Push(Smi::FromInt(expr->literal_index()));
243 __ Push(expr->pattern());
244 __ Push(expr->flags());
245 __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4);
246 // Label done:
247 __ bind(&done);
248 if (expr->location().is_temporary()) {
249 __ push(rax);
250 } else {
251 ASSERT(expr->location().is_nowhere());
252 }
253 }
254
255
225 void FastCodeGenerator::VisitAssignment(Assignment* expr) { 256 void FastCodeGenerator::VisitAssignment(Assignment* expr) {
226 Comment cmnt(masm_, "[ Assignment"); 257 Comment cmnt(masm_, "[ Assignment");
227 ASSERT(expr->op() == Token::ASSIGN || expr->op() == Token::INIT_VAR); 258 ASSERT(expr->op() == Token::ASSIGN || expr->op() == Token::INIT_VAR);
228 Expression* rhs = expr->value(); 259 Expression* rhs = expr->value();
229 Visit(rhs); 260 Visit(rhs);
230 261
231 // Left-hand side can only be a global or a (parameter or local) slot. 262 // Left-hand side can only be a global or a (parameter or local) slot.
232 Variable* var = expr->target()->AsVariableProxy()->AsVariable(); 263 Variable* var = expr->target()->AsVariableProxy()->AsVariable();
233 ASSERT(var != NULL); 264 ASSERT(var != NULL);
234 ASSERT(var->is_global() || var->slot() != NULL); 265 ASSERT(var->is_global() || var->slot() != NULL);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 ASSERT(function != NULL); 365 ASSERT(function != NULL);
335 366
336 // Push the arguments ("left-to-right"). 367 // Push the arguments ("left-to-right").
337 int arg_count = args->length(); 368 int arg_count = args->length();
338 for (int i = 0; i < arg_count; i++) { 369 for (int i = 0; i < arg_count; i++) {
339 Visit(args->at(i)); 370 Visit(args->at(i));
340 ASSERT(!args->at(i)->location().is_nowhere()); 371 ASSERT(!args->at(i)->location().is_nowhere());
341 if (args->at(i)->location().is_constant()) { 372 if (args->at(i)->location().is_constant()) {
342 ASSERT(args->at(i)->AsLiteral() != NULL); 373 ASSERT(args->at(i)->AsLiteral() != NULL);
343 __ Push(args->at(i)->AsLiteral()->handle()); 374 __ Push(args->at(i)->AsLiteral()->handle());
375 } else {
376 ASSERT(args->at(i)->location().is_temporary());
377 // If location is temporary, it is already on the stack,
378 // so nothing to do here.
344 } 379 }
345 } 380 }
346 381
347 __ CallRuntime(function, arg_count); 382 __ CallRuntime(function, arg_count);
348 if (expr->location().is_temporary()) { 383 if (expr->location().is_temporary()) {
349 __ push(rax); 384 __ push(rax);
350 } else { 385 } else {
351 ASSERT(expr->location().is_nowhere()); 386 ASSERT(expr->location().is_nowhere());
352 } 387 }
353 } 388 }
354 389
355 390
356 } } // namespace v8::internal 391 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/fast-codegen-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698