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

Side by Side Diff: src/ia32/fast-codegen-ia32.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/fast-codegen.cc ('k') | src/x64/fast-codegen-x64.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 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 ASSERT(slot != NULL); 199 ASSERT(slot != NULL);
200 if (expr->location().is_temporary()) { 200 if (expr->location().is_temporary()) {
201 __ push(Operand(ebp, SlotOffset(slot))); 201 __ push(Operand(ebp, SlotOffset(slot)));
202 } else { 202 } else {
203 ASSERT(expr->location().is_nowhere()); 203 ASSERT(expr->location().is_nowhere());
204 } 204 }
205 } 205 }
206 } 206 }
207 207
208 208
209 void FastCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
210 Comment cmnt(masm_, "[ RegExp Literal");
211 Label done;
212 // Registers will be used as follows:
213 // edi = JS function.
214 // ebx = literals array.
215 // eax = regexp literal.
216 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
217 __ mov(ebx, FieldOperand(edi, JSFunction::kLiteralsOffset));
218 int literal_offset =
219 FixedArray::kHeaderSize + expr->literal_index() * kPointerSize;
220 __ mov(eax, FieldOperand(ebx, literal_offset));
221 __ cmp(eax, Factory::undefined_value());
222 __ j(not_equal, &done);
223 // Create regexp literal using runtime function
224 // Result will be in eax.
225 __ push(ebx);
226 __ push(Immediate(Smi::FromInt(expr->literal_index())));
227 __ push(Immediate(expr->pattern()));
228 __ push(Immediate(expr->flags()));
229 __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4);
230 // Label done:
231 __ bind(&done);
232 if (expr->location().is_temporary()) {
233 __ push(eax);
234 } else {
235 ASSERT(expr->location().is_nowhere());
236 }
237 }
238
239
209 void FastCodeGenerator::VisitAssignment(Assignment* expr) { 240 void FastCodeGenerator::VisitAssignment(Assignment* expr) {
210 Comment cmnt(masm_, "[ Assignment"); 241 Comment cmnt(masm_, "[ Assignment");
211 ASSERT(expr->op() == Token::ASSIGN || expr->op() == Token::INIT_VAR); 242 ASSERT(expr->op() == Token::ASSIGN || expr->op() == Token::INIT_VAR);
212 Expression* rhs = expr->value(); 243 Expression* rhs = expr->value();
213 Visit(rhs); 244 Visit(rhs);
214 245
215 // Left-hand side can only be a global or a (parameter or local) slot. 246 // Left-hand side can only be a global or a (parameter or local) slot.
216 Variable* var = expr->target()->AsVariableProxy()->AsVariable(); 247 Variable* var = expr->target()->AsVariableProxy()->AsVariable();
217 ASSERT(var != NULL); 248 ASSERT(var != NULL);
218 ASSERT(var->is_global() || var->slot() != NULL); 249 ASSERT(var->is_global() || var->slot() != NULL);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 ASSERT(function != NULL); 352 ASSERT(function != NULL);
322 353
323 // Push the arguments ("left-to-right"). 354 // Push the arguments ("left-to-right").
324 int arg_count = args->length(); 355 int arg_count = args->length();
325 for (int i = 0; i < arg_count; i++) { 356 for (int i = 0; i < arg_count; i++) {
326 Visit(args->at(i)); 357 Visit(args->at(i));
327 ASSERT(!args->at(i)->location().is_nowhere()); 358 ASSERT(!args->at(i)->location().is_nowhere());
328 if (args->at(i)->location().is_constant()) { 359 if (args->at(i)->location().is_constant()) {
329 ASSERT(args->at(i)->AsLiteral() != NULL); 360 ASSERT(args->at(i)->AsLiteral() != NULL);
330 __ push(Immediate(args->at(i)->AsLiteral()->handle())); 361 __ push(Immediate(args->at(i)->AsLiteral()->handle()));
362 } else {
363 ASSERT(args->at(i)->location().is_temporary());
364 // If location is temporary, it is already on the stack,
365 // so nothing to do here.
331 } 366 }
332 } 367 }
333 368
334 __ CallRuntime(function, arg_count); 369 __ CallRuntime(function, arg_count);
335 if (expr->location().is_temporary()) { 370 if (expr->location().is_temporary()) {
336 __ push(eax); 371 __ push(eax);
337 } else { 372 } else {
338 ASSERT(expr->location().is_nowhere()); 373 ASSERT(expr->location().is_nowhere());
339 } 374 }
340 } 375 }
341 376
342 377
343 } } // namespace v8::internal 378 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/fast-codegen.cc ('k') | src/x64/fast-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698