| OLD | NEW |
| 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 | 4 |
| 5 #include "src/builtins/builtins-utils.h" | 5 #include "src/builtins/builtins-utils.h" |
| 6 #include "src/builtins/builtins.h" | 6 #include "src/builtins/builtins.h" |
| 7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
| 8 #include "src/code-stub-assembler.h" | 8 #include "src/code-stub-assembler.h" |
| 9 #include "src/regexp/jsregexp.h" | 9 #include "src/regexp/jsregexp.h" |
| 10 #include "src/regexp/regexp-utils.h" | 10 #include "src/regexp/regexp-utils.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 var_to_cursor.Bind(IntPtrConstant(1)); | 176 var_to_cursor.Bind(IntPtrConstant(1)); |
| 177 | 177 |
| 178 Variable* vars[] = {&var_from_cursor, &var_to_cursor}; | 178 Variable* vars[] = {&var_from_cursor, &var_to_cursor}; |
| 179 Label loop(this, 2, vars); | 179 Label loop(this, 2, vars); |
| 180 | 180 |
| 181 Goto(&loop); | 181 Goto(&loop); |
| 182 Bind(&loop); | 182 Bind(&loop); |
| 183 { | 183 { |
| 184 Node* const from_cursor = var_from_cursor.value(); | 184 Node* const from_cursor = var_from_cursor.value(); |
| 185 Node* const to_cursor = var_to_cursor.value(); | 185 Node* const to_cursor = var_to_cursor.value(); |
| 186 Node* const start = | 186 Node* const start = LoadFixedArrayElement(match_info, from_cursor); |
| 187 LoadFixedArrayElement(match_info, from_cursor, 0, INTPTR_PARAMETERS); | |
| 188 | 187 |
| 189 Label next_iter(this); | 188 Label next_iter(this); |
| 190 GotoIf(SmiEqual(start, SmiConstant(Smi::FromInt(-1))), &next_iter); | 189 GotoIf(SmiEqual(start, SmiConstant(Smi::FromInt(-1))), &next_iter); |
| 191 | 190 |
| 192 Node* const from_cursor_plus1 = IntPtrAdd(from_cursor, IntPtrConstant(1)); | 191 Node* const from_cursor_plus1 = IntPtrAdd(from_cursor, IntPtrConstant(1)); |
| 193 Node* const end = LoadFixedArrayElement(match_info, from_cursor_plus1, 0, | 192 Node* const end = LoadFixedArrayElement(match_info, from_cursor_plus1); |
| 194 INTPTR_PARAMETERS); | |
| 195 | 193 |
| 196 Node* const capture = SubString(context, string, start, end); | 194 Node* const capture = SubString(context, string, start, end); |
| 197 StoreFixedArrayElement(result_elements, to_cursor, capture, | 195 StoreFixedArrayElement(result_elements, to_cursor, capture); |
| 198 UPDATE_WRITE_BARRIER, 0, INTPTR_PARAMETERS); | |
| 199 Goto(&next_iter); | 196 Goto(&next_iter); |
| 200 | 197 |
| 201 Bind(&next_iter); | 198 Bind(&next_iter); |
| 202 var_from_cursor.Bind(IntPtrAdd(from_cursor, IntPtrConstant(2))); | 199 var_from_cursor.Bind(IntPtrAdd(from_cursor, IntPtrConstant(2))); |
| 203 var_to_cursor.Bind(IntPtrAdd(to_cursor, IntPtrConstant(1))); | 200 var_to_cursor.Bind(IntPtrAdd(to_cursor, IntPtrConstant(1))); |
| 204 Branch(UintPtrLessThan(var_from_cursor.value(), limit), &loop, &out); | 201 Branch(UintPtrLessThan(var_from_cursor.value(), limit), &loop, &out); |
| 205 } | 202 } |
| 206 | 203 |
| 207 Bind(&out); | 204 Bind(&out); |
| 208 return result; | 205 return result; |
| (...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1370 | 1367 |
| 1371 Node* length() const { return var_length_.value(); } | 1368 Node* length() const { return var_length_.value(); } |
| 1372 | 1369 |
| 1373 Variable* var_array() { return &var_array_; } | 1370 Variable* var_array() { return &var_array_; } |
| 1374 Variable* var_length() { return &var_length_; } | 1371 Variable* var_length() { return &var_length_; } |
| 1375 Variable* var_capacity() { return &var_capacity_; } | 1372 Variable* var_capacity() { return &var_capacity_; } |
| 1376 | 1373 |
| 1377 void Push(Node* const value) { | 1374 void Push(Node* const value) { |
| 1378 CodeStubAssembler* a = assembler_; | 1375 CodeStubAssembler* a = assembler_; |
| 1379 | 1376 |
| 1380 const WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER; | |
| 1381 const ParameterMode mode = CodeStubAssembler::INTPTR_PARAMETERS; | |
| 1382 | |
| 1383 Node* const length = var_length_.value(); | 1377 Node* const length = var_length_.value(); |
| 1384 Node* const capacity = var_capacity_.value(); | 1378 Node* const capacity = var_capacity_.value(); |
| 1385 | 1379 |
| 1386 Label grow(a), store(a); | 1380 Label grow(a), store(a); |
| 1387 a->Branch(a->IntPtrEqual(capacity, length), &grow, &store); | 1381 a->Branch(a->IntPtrEqual(capacity, length), &grow, &store); |
| 1388 | 1382 |
| 1389 a->Bind(&grow); | 1383 a->Bind(&grow); |
| 1390 { | 1384 { |
| 1391 Node* const new_capacity = NewCapacity(a, capacity); | 1385 Node* const new_capacity = NewCapacity(a, capacity); |
| 1392 Node* const new_array = ResizeFixedArray(length, new_capacity, mode); | 1386 Node* const new_array = ResizeFixedArray(length, new_capacity); |
| 1393 | 1387 |
| 1394 var_capacity_.Bind(new_capacity); | 1388 var_capacity_.Bind(new_capacity); |
| 1395 var_array_.Bind(new_array); | 1389 var_array_.Bind(new_array); |
| 1396 a->Goto(&store); | 1390 a->Goto(&store); |
| 1397 } | 1391 } |
| 1398 | 1392 |
| 1399 a->Bind(&store); | 1393 a->Bind(&store); |
| 1400 { | 1394 { |
| 1401 Node* const array = var_array_.value(); | 1395 Node* const array = var_array_.value(); |
| 1402 a->StoreFixedArrayElement(array, length, value, barrier_mode, 0, mode); | 1396 a->StoreFixedArrayElement(array, length, value); |
| 1403 | 1397 |
| 1404 Node* const new_length = a->IntPtrAdd(length, a->IntPtrConstant(1)); | 1398 Node* const new_length = a->IntPtrAdd(length, a->IntPtrConstant(1)); |
| 1405 var_length_.Bind(new_length); | 1399 var_length_.Bind(new_length); |
| 1406 } | 1400 } |
| 1407 } | 1401 } |
| 1408 | 1402 |
| 1409 Node* ToJSArray(Node* const context) { | 1403 Node* ToJSArray(Node* const context) { |
| 1410 CodeStubAssembler* a = assembler_; | 1404 CodeStubAssembler* a = assembler_; |
| 1411 | 1405 |
| 1412 const ElementsKind kind = FAST_ELEMENTS; | 1406 const ElementsKind kind = FAST_ELEMENTS; |
| 1413 const ParameterMode mode = CodeStubAssembler::INTPTR_PARAMETERS; | |
| 1414 | 1407 |
| 1415 Node* const native_context = a->LoadNativeContext(context); | 1408 Node* const native_context = a->LoadNativeContext(context); |
| 1416 Node* const array_map = a->LoadJSArrayElementsMap(kind, native_context); | 1409 Node* const array_map = a->LoadJSArrayElementsMap(kind, native_context); |
| 1417 | 1410 |
| 1418 // Shrink to fit if necessary. | 1411 // Shrink to fit if necessary. |
| 1419 { | 1412 { |
| 1420 Label next(a); | 1413 Label next(a); |
| 1421 | 1414 |
| 1422 Node* const length = var_length_.value(); | 1415 Node* const length = var_length_.value(); |
| 1423 Node* const capacity = var_capacity_.value(); | 1416 Node* const capacity = var_capacity_.value(); |
| 1424 | 1417 |
| 1425 a->GotoIf(a->WordEqual(length, capacity), &next); | 1418 a->GotoIf(a->WordEqual(length, capacity), &next); |
| 1426 | 1419 |
| 1427 Node* const array = ResizeFixedArray(length, length, mode); | 1420 Node* const array = ResizeFixedArray(length, length); |
| 1428 var_array_.Bind(array); | 1421 var_array_.Bind(array); |
| 1429 var_capacity_.Bind(length); | 1422 var_capacity_.Bind(length); |
| 1430 a->Goto(&next); | 1423 a->Goto(&next); |
| 1431 | 1424 |
| 1432 a->Bind(&next); | 1425 a->Bind(&next); |
| 1433 } | 1426 } |
| 1434 | 1427 |
| 1435 Node* const result_length = a->SmiTag(length()); | 1428 Node* const result_length = a->SmiTag(length()); |
| 1436 Node* const result = a->AllocateUninitializedJSArrayWithoutElements( | 1429 Node* const result = a->AllocateUninitializedJSArrayWithoutElements( |
| 1437 kind, array_map, result_length, nullptr); | 1430 kind, array_map, result_length, nullptr); |
| 1438 | 1431 |
| 1439 // Note: We do not currently shrink the fixed array. | 1432 // Note: We do not currently shrink the fixed array. |
| 1440 | 1433 |
| 1441 a->StoreObjectField(result, JSObject::kElementsOffset, var_array_.value()); | 1434 a->StoreObjectField(result, JSObject::kElementsOffset, var_array_.value()); |
| 1442 | 1435 |
| 1443 return result; | 1436 return result; |
| 1444 } | 1437 } |
| 1445 | 1438 |
| 1446 private: | 1439 private: |
| 1447 void Initialize() { | 1440 void Initialize() { |
| 1448 CodeStubAssembler* a = assembler_; | 1441 CodeStubAssembler* a = assembler_; |
| 1449 | 1442 |
| 1450 const ElementsKind kind = FAST_ELEMENTS; | 1443 const ElementsKind kind = FAST_ELEMENTS; |
| 1451 const ParameterMode mode = CodeStubAssembler::INTPTR_PARAMETERS; | |
| 1452 | 1444 |
| 1453 static const int kInitialArraySize = 8; | 1445 static const int kInitialArraySize = 8; |
| 1454 Node* const capacity = a->IntPtrConstant(kInitialArraySize); | 1446 Node* const capacity = a->IntPtrConstant(kInitialArraySize); |
| 1455 Node* const array = a->AllocateFixedArray(kind, capacity, mode); | 1447 Node* const array = a->AllocateFixedArray(kind, capacity); |
| 1456 | 1448 |
| 1457 a->FillFixedArrayWithValue(kind, array, a->IntPtrConstant(0), capacity, | 1449 a->FillFixedArrayWithValue(kind, array, a->IntPtrConstant(0), capacity, |
| 1458 Heap::kTheHoleValueRootIndex, mode); | 1450 Heap::kTheHoleValueRootIndex); |
| 1459 | 1451 |
| 1460 var_array_.Bind(array); | 1452 var_array_.Bind(array); |
| 1461 var_capacity_.Bind(capacity); | 1453 var_capacity_.Bind(capacity); |
| 1462 var_length_.Bind(a->IntPtrConstant(0)); | 1454 var_length_.Bind(a->IntPtrConstant(0)); |
| 1463 } | 1455 } |
| 1464 | 1456 |
| 1465 Node* NewCapacity(CodeStubAssembler* a, Node* const current_capacity) { | 1457 Node* NewCapacity(CodeStubAssembler* a, Node* const current_capacity) { |
| 1466 CSA_ASSERT(a, a->IntPtrGreaterThan(current_capacity, a->IntPtrConstant(0))); | 1458 CSA_ASSERT(a, a->IntPtrGreaterThan(current_capacity, a->IntPtrConstant(0))); |
| 1467 | 1459 |
| 1468 // Growth rate is analog to JSObject::NewElementsCapacity: | 1460 // Growth rate is analog to JSObject::NewElementsCapacity: |
| 1469 // new_capacity = (current_capacity + (current_capacity >> 1)) + 16. | 1461 // new_capacity = (current_capacity + (current_capacity >> 1)) + 16. |
| 1470 | 1462 |
| 1471 Node* const new_capacity = a->IntPtrAdd( | 1463 Node* const new_capacity = a->IntPtrAdd( |
| 1472 a->IntPtrAdd(current_capacity, a->WordShr(current_capacity, 1)), | 1464 a->IntPtrAdd(current_capacity, a->WordShr(current_capacity, 1)), |
| 1473 a->IntPtrConstant(16)); | 1465 a->IntPtrConstant(16)); |
| 1474 | 1466 |
| 1475 return new_capacity; | 1467 return new_capacity; |
| 1476 } | 1468 } |
| 1477 | 1469 |
| 1478 // Creates a new array with {new_capacity} and copies the first | 1470 // Creates a new array with {new_capacity} and copies the first |
| 1479 // {element_count} elements from the current array. | 1471 // {element_count} elements from the current array. |
| 1480 Node* ResizeFixedArray(Node* const element_count, Node* const new_capacity, | 1472 Node* ResizeFixedArray(Node* const element_count, Node* const new_capacity) { |
| 1481 ParameterMode mode) { | |
| 1482 DCHECK(mode == CodeStubAssembler::INTPTR_PARAMETERS); | |
| 1483 | |
| 1484 CodeStubAssembler* a = assembler_; | 1473 CodeStubAssembler* a = assembler_; |
| 1485 | 1474 |
| 1486 CSA_ASSERT(a, a->IntPtrGreaterThan(element_count, a->IntPtrConstant(0))); | 1475 CSA_ASSERT(a, a->IntPtrGreaterThan(element_count, a->IntPtrConstant(0))); |
| 1487 CSA_ASSERT(a, a->IntPtrGreaterThan(new_capacity, a->IntPtrConstant(0))); | 1476 CSA_ASSERT(a, a->IntPtrGreaterThan(new_capacity, a->IntPtrConstant(0))); |
| 1488 CSA_ASSERT(a, a->IntPtrGreaterThanOrEqual(new_capacity, element_count)); | 1477 CSA_ASSERT(a, a->IntPtrGreaterThanOrEqual(new_capacity, element_count)); |
| 1489 | 1478 |
| 1490 const ElementsKind kind = FAST_ELEMENTS; | 1479 const ElementsKind kind = FAST_ELEMENTS; |
| 1491 const WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER; | 1480 const WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER; |
| 1481 const ParameterMode mode = CodeStubAssembler::INTPTR_PARAMETERS; |
| 1492 const CodeStubAssembler::AllocationFlags flags = | 1482 const CodeStubAssembler::AllocationFlags flags = |
| 1493 CodeStubAssembler::kAllowLargeObjectAllocation; | 1483 CodeStubAssembler::kAllowLargeObjectAllocation; |
| 1494 | 1484 |
| 1495 Node* const from_array = var_array_.value(); | 1485 Node* const from_array = var_array_.value(); |
| 1496 Node* const to_array = | 1486 Node* const to_array = |
| 1497 a->AllocateFixedArray(kind, new_capacity, mode, flags); | 1487 a->AllocateFixedArray(kind, new_capacity, mode, flags); |
| 1498 a->CopyFixedArrayElements(kind, from_array, kind, to_array, element_count, | 1488 a->CopyFixedArrayElements(kind, from_array, kind, to_array, element_count, |
| 1499 new_capacity, barrier_mode, mode); | 1489 new_capacity, barrier_mode, mode); |
| 1500 | 1490 |
| 1501 return to_array; | 1491 return to_array; |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2198 var_i.Bind(int_zero); | 2188 var_i.Bind(int_zero); |
| 2199 | 2189 |
| 2200 Variable* vars[] = {&var_i, &var_match_start}; | 2190 Variable* vars[] = {&var_i, &var_match_start}; |
| 2201 Label loop(this, 2, vars); | 2191 Label loop(this, 2, vars); |
| 2202 Goto(&loop); | 2192 Goto(&loop); |
| 2203 Bind(&loop); | 2193 Bind(&loop); |
| 2204 { | 2194 { |
| 2205 Node* const i = var_i.value(); | 2195 Node* const i = var_i.value(); |
| 2206 GotoUnless(IntPtrLessThan(i, end), &create_result); | 2196 GotoUnless(IntPtrLessThan(i, end), &create_result); |
| 2207 | 2197 |
| 2208 ParameterMode mode = CodeStubAssembler::INTPTR_PARAMETERS; | 2198 Node* const elem = LoadFixedArrayElement(res_elems, i); |
| 2209 Node* const elem = LoadFixedArrayElement(res_elems, i, 0, mode); | |
| 2210 | 2199 |
| 2211 Label if_issmi(this), if_isstring(this), loop_epilogue(this); | 2200 Label if_issmi(this), if_isstring(this), loop_epilogue(this); |
| 2212 Branch(TaggedIsSmi(elem), &if_issmi, &if_isstring); | 2201 Branch(TaggedIsSmi(elem), &if_issmi, &if_isstring); |
| 2213 | 2202 |
| 2214 Bind(&if_issmi); | 2203 Bind(&if_issmi); |
| 2215 { | 2204 { |
| 2216 // Integers represent slices of the original string. | 2205 // Integers represent slices of the original string. |
| 2217 Label if_isnegativeorzero(this), if_ispositive(this); | 2206 Label if_isnegativeorzero(this), if_ispositive(this); |
| 2218 BranchIfSmiLessThanOrEqual(elem, smi_zero, &if_isnegativeorzero, | 2207 BranchIfSmiLessThanOrEqual(elem, smi_zero, &if_isnegativeorzero, |
| 2219 &if_ispositive); | 2208 &if_ispositive); |
| 2220 | 2209 |
| 2221 Bind(&if_ispositive); | 2210 Bind(&if_ispositive); |
| 2222 { | 2211 { |
| 2223 Node* const int_elem = SmiUntag(elem); | 2212 Node* const int_elem = SmiUntag(elem); |
| 2224 Node* const new_match_start = | 2213 Node* const new_match_start = |
| 2225 IntPtrAdd(WordShr(int_elem, IntPtrConstant(11)), | 2214 IntPtrAdd(WordShr(int_elem, IntPtrConstant(11)), |
| 2226 WordAnd(int_elem, IntPtrConstant(0x7ff))); | 2215 WordAnd(int_elem, IntPtrConstant(0x7ff))); |
| 2227 var_match_start.Bind(SmiTag(new_match_start)); | 2216 var_match_start.Bind(SmiTag(new_match_start)); |
| 2228 Goto(&loop_epilogue); | 2217 Goto(&loop_epilogue); |
| 2229 } | 2218 } |
| 2230 | 2219 |
| 2231 Bind(&if_isnegativeorzero); | 2220 Bind(&if_isnegativeorzero); |
| 2232 { | 2221 { |
| 2233 Node* const next_i = IntPtrAdd(i, int_one); | 2222 Node* const next_i = IntPtrAdd(i, int_one); |
| 2234 var_i.Bind(next_i); | 2223 var_i.Bind(next_i); |
| 2235 | 2224 |
| 2236 Node* const next_elem = | 2225 Node* const next_elem = LoadFixedArrayElement(res_elems, next_i); |
| 2237 LoadFixedArrayElement(res_elems, next_i, 0, mode); | |
| 2238 | 2226 |
| 2239 Node* const new_match_start = SmiSub(next_elem, elem); | 2227 Node* const new_match_start = SmiSub(next_elem, elem); |
| 2240 var_match_start.Bind(new_match_start); | 2228 var_match_start.Bind(new_match_start); |
| 2241 Goto(&loop_epilogue); | 2229 Goto(&loop_epilogue); |
| 2242 } | 2230 } |
| 2243 } | 2231 } |
| 2244 | 2232 |
| 2245 Bind(&if_isstring); | 2233 Bind(&if_isstring); |
| 2246 { | 2234 { |
| 2247 CSA_ASSERT(this, IsStringInstanceType(LoadInstanceType(elem))); | 2235 CSA_ASSERT(this, IsStringInstanceType(LoadInstanceType(elem))); |
| 2248 | 2236 |
| 2249 Callable call_callable = CodeFactory::Call(isolate); | 2237 Callable call_callable = CodeFactory::Call(isolate); |
| 2250 Node* const replacement_obj = | 2238 Node* const replacement_obj = |
| 2251 CallJS(call_callable, context, replace_callable, undefined, elem, | 2239 CallJS(call_callable, context, replace_callable, undefined, elem, |
| 2252 var_match_start.value(), string); | 2240 var_match_start.value(), string); |
| 2253 | 2241 |
| 2254 Node* const replacement_str = ToString(context, replacement_obj); | 2242 Node* const replacement_str = ToString(context, replacement_obj); |
| 2255 StoreFixedArrayElement(res_elems, i, replacement_str, | 2243 StoreFixedArrayElement(res_elems, i, replacement_str); |
| 2256 UPDATE_WRITE_BARRIER, 0, mode); | |
| 2257 | 2244 |
| 2258 Node* const elem_length = LoadStringLength(elem); | 2245 Node* const elem_length = LoadStringLength(elem); |
| 2259 Node* const new_match_start = | 2246 Node* const new_match_start = |
| 2260 SmiAdd(var_match_start.value(), elem_length); | 2247 SmiAdd(var_match_start.value(), elem_length); |
| 2261 var_match_start.Bind(new_match_start); | 2248 var_match_start.Bind(new_match_start); |
| 2262 | 2249 |
| 2263 Goto(&loop_epilogue); | 2250 Goto(&loop_epilogue); |
| 2264 } | 2251 } |
| 2265 | 2252 |
| 2266 Bind(&loop_epilogue); | 2253 Bind(&loop_epilogue); |
| 2267 { | 2254 { |
| 2268 var_i.Bind(IntPtrAdd(var_i.value(), int_one)); | 2255 var_i.Bind(IntPtrAdd(var_i.value(), int_one)); |
| 2269 Goto(&loop); | 2256 Goto(&loop); |
| 2270 } | 2257 } |
| 2271 } | 2258 } |
| 2272 } | 2259 } |
| 2273 | 2260 |
| 2274 Bind(&if_hasexplicitcaptures); | 2261 Bind(&if_hasexplicitcaptures); |
| 2275 { | 2262 { |
| 2276 ParameterMode mode = CodeStubAssembler::INTPTR_PARAMETERS; | |
| 2277 | |
| 2278 Node* const from = int_zero; | 2263 Node* const from = int_zero; |
| 2279 Node* const to = SmiUntag(res_length); | 2264 Node* const to = SmiUntag(res_length); |
| 2280 const int increment = 1; | 2265 const int increment = 1; |
| 2281 | 2266 |
| 2282 BuildFastLoop( | 2267 BuildFastLoop( |
| 2283 MachineType::PointerRepresentation(), from, to, | 2268 MachineType::PointerRepresentation(), from, to, |
| 2284 [this, res_elems, isolate, native_context, context, undefined, | 2269 [this, res_elems, isolate, native_context, context, undefined, |
| 2285 replace_callable, mode](Node* index) { | 2270 replace_callable](Node* index) { |
| 2286 Node* const elem = LoadFixedArrayElement(res_elems, index, 0, mode); | 2271 Node* const elem = LoadFixedArrayElement(res_elems, index); |
| 2287 | 2272 |
| 2288 Label do_continue(this); | 2273 Label do_continue(this); |
| 2289 GotoIf(TaggedIsSmi(elem), &do_continue); | 2274 GotoIf(TaggedIsSmi(elem), &do_continue); |
| 2290 | 2275 |
| 2291 // elem must be an Array. | 2276 // elem must be an Array. |
| 2292 // Use the apply argument as backing for global RegExp properties. | 2277 // Use the apply argument as backing for global RegExp properties. |
| 2293 | 2278 |
| 2294 CSA_ASSERT(this, HasInstanceType(elem, JS_ARRAY_TYPE)); | 2279 CSA_ASSERT(this, HasInstanceType(elem, JS_ARRAY_TYPE)); |
| 2295 | 2280 |
| 2296 // TODO(jgruber): Remove indirection through Call->ReflectApply. | 2281 // TODO(jgruber): Remove indirection through Call->ReflectApply. |
| 2297 Callable call_callable = CodeFactory::Call(isolate); | 2282 Callable call_callable = CodeFactory::Call(isolate); |
| 2298 Node* const reflect_apply = | 2283 Node* const reflect_apply = |
| 2299 LoadContextElement(native_context, Context::REFLECT_APPLY_INDEX); | 2284 LoadContextElement(native_context, Context::REFLECT_APPLY_INDEX); |
| 2300 | 2285 |
| 2301 Node* const replacement_obj = | 2286 Node* const replacement_obj = |
| 2302 CallJS(call_callable, context, reflect_apply, undefined, | 2287 CallJS(call_callable, context, reflect_apply, undefined, |
| 2303 replace_callable, undefined, elem); | 2288 replace_callable, undefined, elem); |
| 2304 | 2289 |
| 2305 // Overwrite the i'th element in the results with the string we got | 2290 // Overwrite the i'th element in the results with the string we got |
| 2306 // back from the callback function. | 2291 // back from the callback function. |
| 2307 | 2292 |
| 2308 Node* const replacement_str = ToString(context, replacement_obj); | 2293 Node* const replacement_str = ToString(context, replacement_obj); |
| 2309 StoreFixedArrayElement(res_elems, index, replacement_str, | 2294 StoreFixedArrayElement(res_elems, index, replacement_str); |
| 2310 UPDATE_WRITE_BARRIER, 0, mode); | |
| 2311 | 2295 |
| 2312 Goto(&do_continue); | 2296 Goto(&do_continue); |
| 2313 Bind(&do_continue); | 2297 Bind(&do_continue); |
| 2314 }, | 2298 }, |
| 2315 increment, CodeStubAssembler::IndexAdvanceMode::kPost); | 2299 increment, CodeStubAssembler::IndexAdvanceMode::kPost); |
| 2316 | 2300 |
| 2317 Goto(&create_result); | 2301 Goto(&create_result); |
| 2318 } | 2302 } |
| 2319 | 2303 |
| 2320 Bind(&create_result); | 2304 Bind(&create_result); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2546 Bind(&if_matched); | 2530 Bind(&if_matched); |
| 2547 { | 2531 { |
| 2548 Node* result = | 2532 Node* result = |
| 2549 ConstructNewResultFromMatchInfo(context, match_indices, string); | 2533 ConstructNewResultFromMatchInfo(context, match_indices, string); |
| 2550 Return(result); | 2534 Return(result); |
| 2551 } | 2535 } |
| 2552 } | 2536 } |
| 2553 | 2537 |
| 2554 } // namespace internal | 2538 } // namespace internal |
| 2555 } // namespace v8 | 2539 } // namespace v8 |
| OLD | NEW |