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

Side by Side Diff: src/builtins.cc

Issue 1924233002: Turn Array.isArray into a Turbofan stub (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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/builtins.h ('k') | src/runtime/runtime.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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.h" 5 #include "src/builtins.h"
6 6
7 #include "src/api-arguments.h" 7 #include "src/api-arguments.h"
8 #include "src/api-natives.h" 8 #include "src/api-natives.h"
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 344
345 345
346 BUILTIN(Illegal) { 346 BUILTIN(Illegal) {
347 UNREACHABLE(); 347 UNREACHABLE();
348 return isolate->heap()->undefined_value(); // Make compiler happy. 348 return isolate->heap()->undefined_value(); // Make compiler happy.
349 } 349 }
350 350
351 351
352 BUILTIN(EmptyFunction) { return isolate->heap()->undefined_value(); } 352 BUILTIN(EmptyFunction) { return isolate->heap()->undefined_value(); }
353 353
354 void Builtins::Generate_ArrayIsArray(CodeStubAssembler* assembler) {
355 typedef compiler::Node Node;
356 typedef CodeStubAssembler::Label Label;
357
358 Node* object = assembler->Parameter(1);
359 Node* context = assembler->Parameter(4);
360
361 Label call_runtime(assembler), return_true(assembler),
362 return_false(assembler);
363
364 assembler->GotoIf(assembler->WordIsSmi(object), &return_false);
365 Node* instance_type = assembler->LoadInstanceType(object);
366
367 assembler->GotoIf(assembler->Word32Equal(
368 instance_type, assembler->Int32Constant(JS_ARRAY_TYPE)),
369 &return_true);
370
371 // TODO(verwaest): Handle proxies in-place.
372 assembler->Branch(assembler->Word32Equal(
373 instance_type, assembler->Int32Constant(JS_PROXY_TYPE)),
374 &call_runtime, &return_false);
375
376 assembler->Bind(&return_true);
377 assembler->Return(assembler->BooleanConstant(true));
378
379 assembler->Bind(&return_false);
380 assembler->Return(assembler->BooleanConstant(false));
381
382 assembler->Bind(&call_runtime);
383 assembler->Return(
384 assembler->CallRuntime(Runtime::kArrayIsArray, context, object));
385 }
386
354 void Builtins::Generate_ObjectHasOwnProperty(CodeStubAssembler* assembler) { 387 void Builtins::Generate_ObjectHasOwnProperty(CodeStubAssembler* assembler) {
355 typedef compiler::Node Node; 388 typedef compiler::Node Node;
356 typedef CodeStubAssembler::Label Label; 389 typedef CodeStubAssembler::Label Label;
357 typedef CodeStubAssembler::Variable Variable; 390 typedef CodeStubAssembler::Variable Variable;
358 391
359 Node* object = assembler->Parameter(0); 392 Node* object = assembler->Parameter(0);
360 Node* key = assembler->Parameter(1); 393 Node* key = assembler->Parameter(1);
361 Node* context = assembler->Parameter(4); 394 Node* context = assembler->Parameter(4);
362 395
363 Label call_runtime(assembler), return_true(assembler), 396 Label call_runtime(assembler), return_true(assembler),
(...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 if (*species == isolate->context()->native_context()->array_function()) { 1635 if (*species == isolate->context()->native_context()->array_function()) {
1603 if (Fast_ArrayConcat(isolate, &args).ToHandle(&result_array)) { 1636 if (Fast_ArrayConcat(isolate, &args).ToHandle(&result_array)) {
1604 return *result_array; 1637 return *result_array;
1605 } 1638 }
1606 if (isolate->has_pending_exception()) return isolate->heap()->exception(); 1639 if (isolate->has_pending_exception()) return isolate->heap()->exception();
1607 } 1640 }
1608 return Slow_ArrayConcat(&args, species, isolate); 1641 return Slow_ArrayConcat(&args, species, isolate);
1609 } 1642 }
1610 1643
1611 1644
1612 // ES6 22.1.2.2 Array.isArray
1613 BUILTIN(ArrayIsArray) {
1614 HandleScope scope(isolate);
1615 DCHECK_EQ(2, args.length());
1616 Handle<Object> object = args.at<Object>(1);
1617 Maybe<bool> result = Object::IsArray(object);
1618 MAYBE_RETURN(result, isolate->heap()->exception());
1619 return *isolate->factory()->ToBoolean(result.FromJust());
1620 }
1621
1622 namespace { 1645 namespace {
1623 1646
1624 MUST_USE_RESULT Maybe<bool> FastAssign(Handle<JSReceiver> to, 1647 MUST_USE_RESULT Maybe<bool> FastAssign(Handle<JSReceiver> to,
1625 Handle<Object> next_source) { 1648 Handle<Object> next_source) {
1626 // Non-empty strings are the only non-JSReceivers that need to be handled 1649 // Non-empty strings are the only non-JSReceivers that need to be handled
1627 // explicitly by Object.assign. 1650 // explicitly by Object.assign.
1628 if (!next_source->IsJSReceiver()) { 1651 if (!next_source->IsJSReceiver()) {
1629 return Just(!next_source->IsString() || 1652 return Just(!next_source->IsString() ||
1630 String::cast(*next_source)->length() == 0); 1653 String::cast(*next_source)->length() == 0);
1631 } 1654 }
(...skipping 3762 matching lines...) Expand 10 before | Expand all | Expand 10 after
5394 BUILTIN_LIST_T(DEFINE_BUILTIN_ACCESSOR_T) 5417 BUILTIN_LIST_T(DEFINE_BUILTIN_ACCESSOR_T)
5395 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) 5418 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H)
5396 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 5419 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
5397 #undef DEFINE_BUILTIN_ACCESSOR_C 5420 #undef DEFINE_BUILTIN_ACCESSOR_C
5398 #undef DEFINE_BUILTIN_ACCESSOR_A 5421 #undef DEFINE_BUILTIN_ACCESSOR_A
5399 #undef DEFINE_BUILTIN_ACCESSOR_T 5422 #undef DEFINE_BUILTIN_ACCESSOR_T
5400 #undef DEFINE_BUILTIN_ACCESSOR_H 5423 #undef DEFINE_BUILTIN_ACCESSOR_H
5401 5424
5402 } // namespace internal 5425 } // namespace internal
5403 } // namespace v8 5426 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698