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

Side by Side Diff: src/arm/full-codegen-arm.cc

Issue 3034060: Create a new RegExp object for every evaluation of a RegExp literal. (Closed)
Patch Set: Addressed review comments. Created 10 years, 4 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/arm/codegen-arm.cc ('k') | src/arm/macro-assembler-arm.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 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 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 // Call keyed load IC. It has arguments key and receiver in r0 and r1. 1097 // Call keyed load IC. It has arguments key and receiver in r0 and r1.
1098 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize)); 1098 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize));
1099 __ Call(ic, RelocInfo::CODE_TARGET); 1099 __ Call(ic, RelocInfo::CODE_TARGET);
1100 Apply(context, r0); 1100 Apply(context, r0);
1101 } 1101 }
1102 } 1102 }
1103 1103
1104 1104
1105 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { 1105 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
1106 Comment cmnt(masm_, "[ RegExpLiteral"); 1106 Comment cmnt(masm_, "[ RegExpLiteral");
1107 Label done; 1107 Label materialized;
1108 // Registers will be used as follows: 1108 // Registers will be used as follows:
1109 // r4 = JS function, literals array 1109 // r4 = JS function, literals array
1110 // r3 = literal index 1110 // r3 = literal index
1111 // r2 = RegExp pattern 1111 // r2 = RegExp pattern
1112 // r1 = RegExp flags 1112 // r1 = RegExp flags
1113 // r0 = temp + return value (RegExp literal) 1113 // r0 = temp + materialized value (RegExp literal)
1114 __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 1114 __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1115 __ ldr(r4, FieldMemOperand(r0, JSFunction::kLiteralsOffset)); 1115 __ ldr(r4, FieldMemOperand(r0, JSFunction::kLiteralsOffset));
1116 int literal_offset = 1116 int literal_offset =
1117 FixedArray::kHeaderSize + expr->literal_index() * kPointerSize; 1117 FixedArray::kHeaderSize + expr->literal_index() * kPointerSize;
1118 __ ldr(r0, FieldMemOperand(r4, literal_offset)); 1118 __ ldr(r0, FieldMemOperand(r4, literal_offset));
1119 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); 1119 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex);
1120 __ cmp(r0, ip); 1120 __ cmp(r0, ip);
1121 __ b(ne, &done); 1121 __ b(ne, &materialized);
1122 __ mov(r3, Operand(Smi::FromInt(expr->literal_index()))); 1122 __ mov(r3, Operand(Smi::FromInt(expr->literal_index())));
1123 __ mov(r2, Operand(expr->pattern())); 1123 __ mov(r2, Operand(expr->pattern()));
1124 __ mov(r1, Operand(expr->flags())); 1124 __ mov(r1, Operand(expr->flags()));
1125 __ Push(r4, r3, r2, r1); 1125 __ Push(r4, r3, r2, r1);
1126 __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4); 1126 __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4);
1127 __ bind(&done); 1127 __ bind(&materialized);
1128 int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
1129 __ push(r0);
1130 __ mov(r0, Operand(Smi::FromInt(size)));
1131 __ push(r0);
1132 __ CallRuntime(Runtime::kAllocateInNewSpace, 1);
1133 // After this, registers are used as follows:
1134 // r0: Newly allocated regexp.
1135 // r1: Materialized regexp
1136 // r2: temp.
1137 __ pop(r1);
1138 __ CopyFields(r0, r1, r2.bit(), size / kPointerSize);
1128 Apply(context_, r0); 1139 Apply(context_, r0);
1129 } 1140 }
1130 1141
1131 1142
1132 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { 1143 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
1133 Comment cmnt(masm_, "[ ObjectLiteral"); 1144 Comment cmnt(masm_, "[ ObjectLiteral");
1134 __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 1145 __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1135 __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset)); 1146 __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset));
1136 __ mov(r2, Operand(Smi::FromInt(expr->literal_index()))); 1147 __ mov(r2, Operand(Smi::FromInt(expr->literal_index())));
1137 __ mov(r1, Operand(expr->constant_properties())); 1148 __ mov(r1, Operand(expr->constant_properties()));
(...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after
2559 __ bind(&not_found); 2570 __ bind(&not_found);
2560 // Call runtime to perform the lookup. 2571 // Call runtime to perform the lookup.
2561 __ Push(cache, key); 2572 __ Push(cache, key);
2562 __ CallRuntime(Runtime::kGetFromCache, 2); 2573 __ CallRuntime(Runtime::kGetFromCache, 2);
2563 2574
2564 __ bind(&done); 2575 __ bind(&done);
2565 Apply(context_, r0); 2576 Apply(context_, r0);
2566 } 2577 }
2567 2578
2568 2579
2580 void FullCodeGenerator::EmitIsRegExpEquivalent(ZoneList<Expression*>* args) {
2581 ASSERT_EQ(2, args->length());
2582
2583 Register right = r0;
2584 Register left = r1;
2585 Register tmp = r2;
2586 Register tmp2 = r3;
2587
2588 VisitForValue(args->at(0), kStack);
2589 VisitForValue(args->at(1), kAccumulator);
2590 __ pop(left);
2591
2592 Label done, fail, ok;
2593 __ cmp(left, Operand(right));
2594 __ b(eq, &ok);
2595 // Fail if either is a non-HeapObject.
2596 __ and_(tmp, left, Operand(right));
2597 __ tst(tmp, Operand(kSmiTagMask));
2598 __ b(eq, &fail);
2599 __ ldr(tmp, FieldMemOperand(left, HeapObject::kMapOffset));
2600 __ ldrb(tmp2, FieldMemOperand(tmp, Map::kInstanceTypeOffset));
2601 __ cmp(tmp2, Operand(JS_REGEXP_TYPE));
2602 __ b(ne, &fail);
2603 __ ldr(tmp2, FieldMemOperand(right, HeapObject::kMapOffset));
2604 __ cmp(tmp, Operand(tmp2));
2605 __ b(ne, &fail);
2606 __ ldr(tmp, FieldMemOperand(left, JSRegExp::kDataOffset));
2607 __ ldr(tmp2, FieldMemOperand(right, JSRegExp::kDataOffset));
2608 __ cmp(tmp, tmp2);
2609 __ b(eq, &ok);
2610 __ bind(&fail);
2611 __ LoadRoot(r0, Heap::kFalseValueRootIndex);
2612 __ jmp(&done);
2613 __ bind(&ok);
2614 __ LoadRoot(r0, Heap::kTrueValueRootIndex);
2615 __ bind(&done);
2616
2617 Apply(context_, r0);
2618 }
2619
2620
2569 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { 2621 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
2570 Handle<String> name = expr->name(); 2622 Handle<String> name = expr->name();
2571 if (name->length() > 0 && name->Get(0) == '_') { 2623 if (name->length() > 0 && name->Get(0) == '_') {
2572 Comment cmnt(masm_, "[ InlineRuntimeCall"); 2624 Comment cmnt(masm_, "[ InlineRuntimeCall");
2573 EmitInlineRuntimeCall(expr); 2625 EmitInlineRuntimeCall(expr);
2574 return; 2626 return;
2575 } 2627 }
2576 2628
2577 Comment cmnt(masm_, "[ CallRuntime"); 2629 Comment cmnt(masm_, "[ CallRuntime");
2578 ZoneList<Expression*>* args = expr->arguments(); 2630 ZoneList<Expression*>* args = expr->arguments();
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
3169 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value. 3221 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value.
3170 __ add(pc, r1, Operand(masm_->CodeObject())); 3222 __ add(pc, r1, Operand(masm_->CodeObject()));
3171 } 3223 }
3172 3224
3173 3225
3174 #undef __ 3226 #undef __
3175 3227
3176 } } // namespace v8::internal 3228 } } // namespace v8::internal
3177 3229
3178 #endif // V8_TARGET_ARCH_ARM 3230 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/codegen-arm.cc ('k') | src/arm/macro-assembler-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698