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

Side by Side Diff: src/code-stub-assembler.cc

Issue 2438683005: [regexp] Move RegExp.prototype[@@search] to TF (Closed)
Patch Set: Rebase Created 4 years, 1 month 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/code-stub-assembler.h ('k') | test/mjsunit/regexp.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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 #include "src/code-stub-assembler.h" 4 #include "src/code-stub-assembler.h"
5 #include "src/code-factory.h" 5 #include "src/code-factory.h"
6 #include "src/frames-inl.h" 6 #include "src/frames-inl.h"
7 #include "src/frames.h" 7 #include "src/frames.h"
8 #include "src/ic/handler-configuration.h" 8 #include "src/ic/handler-configuration.h"
9 #include "src/ic/stub-cache.h" 9 #include "src/ic/stub-cache.h"
10 10
(...skipping 2253 matching lines...) Expand 10 before | Expand all | Expand 10 after
2264 if (FLAG_allocation_site_pretenuring) { 2264 if (FLAG_allocation_site_pretenuring) {
2265 Node* count = LoadObjectField(allocation_site, 2265 Node* count = LoadObjectField(allocation_site,
2266 AllocationSite::kPretenureCreateCountOffset); 2266 AllocationSite::kPretenureCreateCountOffset);
2267 Node* incremented_count = SmiAdd(count, SmiConstant(Smi::FromInt(1))); 2267 Node* incremented_count = SmiAdd(count, SmiConstant(Smi::FromInt(1)));
2268 StoreObjectFieldNoWriteBarrier(allocation_site, 2268 StoreObjectFieldNoWriteBarrier(allocation_site,
2269 AllocationSite::kPretenureCreateCountOffset, 2269 AllocationSite::kPretenureCreateCountOffset,
2270 incremented_count); 2270 incremented_count);
2271 } 2271 }
2272 } 2272 }
2273 2273
2274 Node* CodeStubAssembler::TryTaggedToFloat64(Node* value,
2275 Label* if_valueisnotnumber) {
2276 Label out(this);
2277 Variable var_result(this, MachineRepresentation::kFloat64);
2278
2279 // Check if the {value} is a Smi or a HeapObject.
2280 Label if_valueissmi(this), if_valueisnotsmi(this);
2281 Branch(TaggedIsSmi(value), &if_valueissmi, &if_valueisnotsmi);
2282
2283 Bind(&if_valueissmi);
2284 {
2285 // Convert the Smi {value}.
2286 var_result.Bind(SmiToFloat64(value));
2287 Goto(&out);
2288 }
2289
2290 Bind(&if_valueisnotsmi);
2291 {
2292 // Check if {value} is a HeapNumber.
2293 Label if_valueisheapnumber(this);
2294 Branch(IsHeapNumberMap(LoadMap(value)), &if_valueisheapnumber,
2295 if_valueisnotnumber);
2296
2297 Bind(&if_valueisheapnumber);
2298 {
2299 // Load the floating point value.
2300 var_result.Bind(LoadHeapNumberValue(value));
2301 Goto(&out);
2302 }
2303 }
2304 Bind(&out);
2305 return var_result.value();
2306 }
2307
2274 Node* CodeStubAssembler::TruncateTaggedToFloat64(Node* context, Node* value) { 2308 Node* CodeStubAssembler::TruncateTaggedToFloat64(Node* context, Node* value) {
2275 // We might need to loop once due to ToNumber conversion. 2309 // We might need to loop once due to ToNumber conversion.
2276 Variable var_value(this, MachineRepresentation::kTagged), 2310 Variable var_value(this, MachineRepresentation::kTagged),
2277 var_result(this, MachineRepresentation::kFloat64); 2311 var_result(this, MachineRepresentation::kFloat64);
2278 Label loop(this, &var_value), done_loop(this, &var_result); 2312 Label loop(this, &var_value), done_loop(this, &var_result);
2279 var_value.Bind(value); 2313 var_value.Bind(value);
2280 Goto(&loop); 2314 Goto(&loop);
2281 Bind(&loop); 2315 Bind(&loop);
2282 { 2316 {
2317 Label if_valueisnotnumber(this, Label::kDeferred);
2318
2283 // Load the current {value}. 2319 // Load the current {value}.
2284 value = var_value.value(); 2320 value = var_value.value();
2285 2321
2286 // Check if the {value} is a Smi or a HeapObject. 2322 // Convert {value} to Float64 if it is a number and convert it to a number
2287 Label if_valueissmi(this), if_valueisnotsmi(this); 2323 // otherwise.
2288 Branch(TaggedIsSmi(value), &if_valueissmi, &if_valueisnotsmi); 2324 Node* const result = TryTaggedToFloat64(value, &if_valueisnotnumber);
2325 var_result.Bind(result);
2326 Goto(&done_loop);
2289 2327
2290 Bind(&if_valueissmi); 2328 Bind(&if_valueisnotnumber);
2291 { 2329 {
2292 // Convert the Smi {value}. 2330 // Convert the {value} to a Number first.
2293 var_result.Bind(SmiToFloat64(value)); 2331 Callable callable = CodeFactory::NonNumberToNumber(isolate());
2294 Goto(&done_loop); 2332 var_value.Bind(CallStub(callable, context, value));
2295 } 2333 Goto(&loop);
2296
2297 Bind(&if_valueisnotsmi);
2298 {
2299 // Check if {value} is a HeapNumber.
2300 Label if_valueisheapnumber(this),
2301 if_valueisnotheapnumber(this, Label::kDeferred);
2302 Branch(WordEqual(LoadMap(value), HeapNumberMapConstant()),
2303 &if_valueisheapnumber, &if_valueisnotheapnumber);
2304
2305 Bind(&if_valueisheapnumber);
2306 {
2307 // Load the floating point value.
2308 var_result.Bind(LoadHeapNumberValue(value));
2309 Goto(&done_loop);
2310 }
2311
2312 Bind(&if_valueisnotheapnumber);
2313 {
2314 // Convert the {value} to a Number first.
2315 Callable callable = CodeFactory::NonNumberToNumber(isolate());
2316 var_value.Bind(CallStub(callable, context, value));
2317 Goto(&loop);
2318 }
2319 } 2334 }
2320 } 2335 }
2321 Bind(&done_loop); 2336 Bind(&done_loop);
2322 return var_result.value(); 2337 return var_result.value();
2323 } 2338 }
2324 2339
2325 Node* CodeStubAssembler::TruncateTaggedToWord32(Node* context, Node* value) { 2340 Node* CodeStubAssembler::TruncateTaggedToWord32(Node* context, Node* value) {
2326 // We might need to loop once due to ToNumber conversion. 2341 // We might need to loop once due to ToNumber conversion.
2327 Variable var_value(this, MachineRepresentation::kTagged), 2342 Variable var_value(this, MachineRepresentation::kTagged),
2328 var_result(this, MachineRepresentation::kWord32); 2343 var_result(this, MachineRepresentation::kWord32);
(...skipping 4238 matching lines...) Expand 10 before | Expand all | Expand 10 after
6567 CopyFixedArrayElements(kind, properties, new_properties, length, 6582 CopyFixedArrayElements(kind, properties, new_properties, length,
6568 SKIP_WRITE_BARRIER, mode); 6583 SKIP_WRITE_BARRIER, mode);
6569 6584
6570 StoreObjectField(object, JSObject::kPropertiesOffset, new_properties); 6585 StoreObjectField(object, JSObject::kPropertiesOffset, new_properties);
6571 } 6586 }
6572 6587
6573 Node* CodeStubAssembler::PrepareValueForWrite(Node* value, 6588 Node* CodeStubAssembler::PrepareValueForWrite(Node* value,
6574 Representation representation, 6589 Representation representation,
6575 Label* bailout) { 6590 Label* bailout) {
6576 if (representation.IsDouble()) { 6591 if (representation.IsDouble()) {
6577 Variable var_value(this, MachineRepresentation::kFloat64); 6592 value = TryTaggedToFloat64(value, bailout);
6578 Label if_smi(this), if_heap_object(this), done(this);
6579 Branch(TaggedIsSmi(value), &if_smi, &if_heap_object);
6580 Bind(&if_smi);
6581 {
6582 var_value.Bind(SmiToFloat64(value));
6583 Goto(&done);
6584 }
6585 Bind(&if_heap_object);
6586 {
6587 GotoUnless(
6588 Word32Equal(LoadInstanceType(value), Int32Constant(HEAP_NUMBER_TYPE)),
6589 bailout);
6590 var_value.Bind(LoadHeapNumberValue(value));
6591 Goto(&done);
6592 }
6593 Bind(&done);
6594 value = var_value.value();
6595 } else if (representation.IsHeapObject()) { 6593 } else if (representation.IsHeapObject()) {
6596 // Field type is checked by the handler, here we only check if the value 6594 // Field type is checked by the handler, here we only check if the value
6597 // is a heap object. 6595 // is a heap object.
6598 GotoIf(TaggedIsSmi(value), bailout); 6596 GotoIf(TaggedIsSmi(value), bailout);
6599 } else if (representation.IsSmi()) { 6597 } else if (representation.IsSmi()) {
6600 GotoUnless(TaggedIsSmi(value), bailout); 6598 GotoUnless(TaggedIsSmi(value), bailout);
6601 } else { 6599 } else {
6602 DCHECK(representation.IsTagged()); 6600 DCHECK(representation.IsTagged());
6603 } 6601 }
6604 return value; 6602 return value;
(...skipping 1964 matching lines...) Expand 10 before | Expand all | Expand 10 after
8569 Bind(&if_notequal); 8567 Bind(&if_notequal);
8570 { 8568 {
8571 result.Bind(BooleanConstant(mode == kNegateResult)); 8569 result.Bind(BooleanConstant(mode == kNegateResult));
8572 Goto(&end); 8570 Goto(&end);
8573 } 8571 }
8574 8572
8575 Bind(&end); 8573 Bind(&end);
8576 return result.value(); 8574 return result.value();
8577 } 8575 }
8578 8576
8577 // ECMA#sec-samevalue
8578 // This algorithm differs from the Strict Equality Comparison Algorithm in its
8579 // treatment of signed zeroes and NaNs.
8580 compiler::Node* CodeStubAssembler::SameValue(compiler::Node* lhs,
8581 compiler::Node* rhs,
8582 compiler::Node* context) {
8583 Variable var_result(this, MachineType::PointerRepresentation());
8584 Label strict_equal(this), out(this);
8585
8586 Node* const int_false = IntPtrConstant(0);
8587 Node* const int_true = IntPtrConstant(1);
8588
8589 Label if_equal(this), if_notequal(this);
8590 Branch(WordEqual(lhs, rhs), &if_equal, &if_notequal);
8591
8592 Bind(&if_equal);
8593 {
8594 // This covers the case when {lhs} == {rhs}. We can simply return true
8595 // because SameValue considers two NaNs to be equal.
8596
8597 var_result.Bind(int_true);
8598 Goto(&out);
8599 }
8600
8601 Bind(&if_notequal);
8602 {
8603 // This covers the case when {lhs} != {rhs}. We only handle numbers here
8604 // and defer to StrictEqual for the rest.
8605
8606 Node* const lhs_float = TryTaggedToFloat64(lhs, &strict_equal);
8607 Node* const rhs_float = TryTaggedToFloat64(rhs, &strict_equal);
8608
8609 Label if_lhsisnan(this), if_lhsnotnan(this);
8610 BranchIfFloat64IsNaN(lhs_float, &if_lhsisnan, &if_lhsnotnan);
8611
8612 Bind(&if_lhsisnan);
8613 {
8614 // Return true iff {rhs} is NaN.
8615
8616 Node* const result =
8617 Select(Float64Equal(rhs_float, rhs_float), int_false, int_true,
8618 MachineType::PointerRepresentation());
8619 var_result.Bind(result);
8620 Goto(&out);
8621 }
8622
8623 Bind(&if_lhsnotnan);
8624 {
8625 Label if_floatisequal(this), if_floatnotequal(this);
8626 Branch(Float64Equal(lhs_float, rhs_float), &if_floatisequal,
8627 &if_floatnotequal);
8628
8629 Bind(&if_floatisequal);
8630 {
8631 // We still need to handle the case when {lhs} and {rhs} are -0.0 and
8632 // 0.0 (or vice versa). Compare the high word to
8633 // distinguish between the two.
8634
8635 Node* const lhs_hi_word = Float64ExtractHighWord32(lhs_float);
8636 Node* const rhs_hi_word = Float64ExtractHighWord32(rhs_float);
8637
8638 // If x is +0 and y is -0, return false.
8639 // If x is -0 and y is +0, return false.
8640
8641 Node* const result = Word32Equal(lhs_hi_word, rhs_hi_word);
8642 var_result.Bind(result);
8643 Goto(&out);
8644 }
8645
8646 Bind(&if_floatnotequal);
8647 {
8648 var_result.Bind(int_false);
8649 Goto(&out);
8650 }
8651 }
8652 }
8653
8654 Bind(&strict_equal);
8655 {
8656 Node* const is_equal = StrictEqual(kDontNegateResult, lhs, rhs, context);
8657 Node* const result = WordEqual(is_equal, TrueConstant());
8658 var_result.Bind(result);
8659 Goto(&out);
8660 }
8661
8662 Bind(&out);
8663 return var_result.value();
8664 }
8665
8579 compiler::Node* CodeStubAssembler::ForInFilter(compiler::Node* key, 8666 compiler::Node* CodeStubAssembler::ForInFilter(compiler::Node* key,
8580 compiler::Node* object, 8667 compiler::Node* object,
8581 compiler::Node* context) { 8668 compiler::Node* context) {
8582 Label return_undefined(this, Label::kDeferred), return_to_name(this), 8669 Label return_undefined(this, Label::kDeferred), return_to_name(this),
8583 end(this); 8670 end(this);
8584 8671
8585 Variable var_result(this, MachineRepresentation::kTagged); 8672 Variable var_result(this, MachineRepresentation::kTagged);
8586 8673
8587 Node* has_property = 8674 Node* has_property =
8588 HasProperty(object, key, context, Runtime::kForInHasProperty); 8675 HasProperty(object, key, context, Runtime::kForInHasProperty);
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
9139 STATIC_ASSERT(FAST_HOLEY_ELEMENTS == (FAST_ELEMENTS | 1)); 9226 STATIC_ASSERT(FAST_HOLEY_ELEMENTS == (FAST_ELEMENTS | 1));
9140 STATIC_ASSERT(FAST_HOLEY_DOUBLE_ELEMENTS == (FAST_DOUBLE_ELEMENTS | 1)); 9227 STATIC_ASSERT(FAST_HOLEY_DOUBLE_ELEMENTS == (FAST_DOUBLE_ELEMENTS | 1));
9141 9228
9142 // Check prototype chain if receiver does not have packed elements. 9229 // Check prototype chain if receiver does not have packed elements.
9143 Node* holey_elements = Word32And(elements_kind, Int32Constant(1)); 9230 Node* holey_elements = Word32And(elements_kind, Int32Constant(1));
9144 return Word32Equal(holey_elements, Int32Constant(1)); 9231 return Word32Equal(holey_elements, Int32Constant(1));
9145 } 9232 }
9146 9233
9147 } // namespace internal 9234 } // namespace internal
9148 } // namespace v8 9235 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stub-assembler.h ('k') | test/mjsunit/regexp.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698