| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/base/utils/random-number-generator.h" | 5 #include "src/base/utils/random-number-generator.h" |
| 6 #include "src/builtins/builtins-promise.h" | 6 #include "src/builtins/builtins-promise.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/compiler/node.h" | 9 #include "src/compiler/node.h" |
| 10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 CodeStubAssembler m(data.state()); | 232 CodeStubAssembler m(data.state()); |
| 233 | 233 |
| 234 enum Result { kKeyIsIndex, kKeyIsUnique, kBailout }; | 234 enum Result { kKeyIsIndex, kKeyIsUnique, kBailout }; |
| 235 { | 235 { |
| 236 Node* key = m.Parameter(0); | 236 Node* key = m.Parameter(0); |
| 237 Node* expected_result = m.Parameter(1); | 237 Node* expected_result = m.Parameter(1); |
| 238 Node* expected_arg = m.Parameter(2); | 238 Node* expected_arg = m.Parameter(2); |
| 239 | 239 |
| 240 Label passed(&m), failed(&m); | 240 Label passed(&m), failed(&m); |
| 241 Label if_keyisindex(&m), if_keyisunique(&m), if_bailout(&m); | 241 Label if_keyisindex(&m), if_keyisunique(&m), if_bailout(&m); |
| 242 { | 242 Variable var_index(&m, MachineType::PointerRepresentation()); |
| 243 Variable var_index(&m, MachineType::PointerRepresentation()); | |
| 244 Variable var_unique(&m, MachineRepresentation::kTagged); | |
| 245 | 243 |
| 246 m.TryToName(key, &if_keyisindex, &var_index, &if_keyisunique, &var_unique, | 244 m.TryToName(key, &if_keyisindex, &var_index, &if_keyisunique, &if_bailout); |
| 247 &if_bailout); | |
| 248 | 245 |
| 249 m.Bind(&if_keyisindex); | 246 m.Bind(&if_keyisindex); |
| 250 m.GotoUnless(m.WordEqual(expected_result, | 247 m.GotoUnless( |
| 251 m.SmiConstant(Smi::FromInt(kKeyIsIndex))), | 248 m.WordEqual(expected_result, m.SmiConstant(Smi::FromInt(kKeyIsIndex))), |
| 252 &failed); | 249 &failed); |
| 253 m.Branch(m.WordEqual(m.SmiUntag(expected_arg), var_index.value()), | 250 m.Branch(m.WordEqual(m.SmiUntag(expected_arg), var_index.value()), &passed, |
| 254 &passed, &failed); | 251 &failed); |
| 255 | 252 |
| 256 m.Bind(&if_keyisunique); | 253 m.Bind(&if_keyisunique); |
| 257 m.GotoUnless(m.WordEqual(expected_result, | 254 m.GotoUnless( |
| 258 m.SmiConstant(Smi::FromInt(kKeyIsUnique))), | 255 m.WordEqual(expected_result, m.SmiConstant(Smi::FromInt(kKeyIsUnique))), |
| 259 &failed); | 256 &failed); |
| 260 m.Branch(m.WordEqual(expected_arg, var_unique.value()), &passed, &failed); | 257 m.Branch(m.WordEqual(expected_arg, key), &passed, &failed); |
| 261 } | |
| 262 | 258 |
| 263 m.Bind(&if_bailout); | 259 m.Bind(&if_bailout); |
| 264 m.Branch( | 260 m.Branch( |
| 265 m.WordEqual(expected_result, m.SmiConstant(Smi::FromInt(kBailout))), | 261 m.WordEqual(expected_result, m.SmiConstant(Smi::FromInt(kBailout))), |
| 266 &passed, &failed); | 262 &passed, &failed); |
| 267 | 263 |
| 268 m.Bind(&passed); | 264 m.Bind(&passed); |
| 269 m.Return(m.BooleanConstant(true)); | 265 m.Return(m.BooleanConstant(true)); |
| 270 | 266 |
| 271 m.Bind(&failed); | 267 m.Bind(&failed); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 Handle<String> key = isolate->factory()->NewStringFromAsciiChecked("153"); | 343 Handle<String> key = isolate->factory()->NewStringFromAsciiChecked("153"); |
| 348 CHECK(!key->HasHashCode()); | 344 CHECK(!key->HasHashCode()); |
| 349 ft.CheckTrue(key, expect_bailout); | 345 ft.CheckTrue(key, expect_bailout); |
| 350 } | 346 } |
| 351 | 347 |
| 352 { | 348 { |
| 353 // TryToName(<non-internalized string>) => bailout. | 349 // TryToName(<non-internalized string>) => bailout. |
| 354 Handle<Object> key = isolate->factory()->NewStringFromAsciiChecked("test"); | 350 Handle<Object> key = isolate->factory()->NewStringFromAsciiChecked("test"); |
| 355 ft.CheckTrue(key, expect_bailout); | 351 ft.CheckTrue(key, expect_bailout); |
| 356 } | 352 } |
| 357 | |
| 358 { | |
| 359 // TryToName(<thin string>) => internalized version. | |
| 360 Handle<String> s = isolate->factory()->NewStringFromAsciiChecked("foo"); | |
| 361 Handle<String> internalized = isolate->factory()->InternalizeString(s); | |
| 362 ft.CheckTrue(s, expect_unique, internalized); | |
| 363 } | |
| 364 | |
| 365 { | |
| 366 // TryToName(<thin two-byte string>) => internalized version. | |
| 367 uc16 array1[] = {2001, 2002, 2003}; | |
| 368 Vector<const uc16> str1(array1); | |
| 369 Handle<String> s = | |
| 370 isolate->factory()->NewStringFromTwoByte(str1).ToHandleChecked(); | |
| 371 Handle<String> internalized = isolate->factory()->InternalizeString(s); | |
| 372 ft.CheckTrue(s, expect_unique, internalized); | |
| 373 } | |
| 374 } | 353 } |
| 375 | 354 |
| 376 namespace { | 355 namespace { |
| 377 | 356 |
| 378 template <typename Dictionary> | 357 template <typename Dictionary> |
| 379 void TestEntryToIndex() { | 358 void TestEntryToIndex() { |
| 380 Isolate* isolate(CcTest::InitIsolateOnce()); | 359 Isolate* isolate(CcTest::InitIsolateOnce()); |
| 381 | 360 |
| 382 const int kNumParams = 1; | 361 const int kNumParams = 1; |
| 383 CodeAssemblerTester data(isolate, kNumParams); | 362 CodeAssemblerTester data(isolate, kNumParams); |
| (...skipping 1866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2250 .ToHandleChecked(); | 2229 .ToHandleChecked(); |
| 2251 Handle<Object> prop2 = | 2230 Handle<Object> prop2 = |
| 2252 JSReceiver::GetProperty(isolate, promise, "rejectedReason") | 2231 JSReceiver::GetProperty(isolate, promise, "rejectedReason") |
| 2253 .ToHandleChecked(); | 2232 .ToHandleChecked(); |
| 2254 CHECK_EQ(*rejected_str, *prop2); | 2233 CHECK_EQ(*rejected_str, *prop2); |
| 2255 } | 2234 } |
| 2256 } | 2235 } |
| 2257 | 2236 |
| 2258 } // namespace internal | 2237 } // namespace internal |
| 2259 } // namespace v8 | 2238 } // namespace v8 |
| OLD | NEW |