Commit 29a2e8f8 authored by balazs.kilvady's avatar balazs.kilvady Committed by Commit bot

MIPS: Refine '[es6] Introduce a dedicated JSIteratorResult type.'

Port 72bc4b5c

Original commit message:
Use a single JSIteratorResult type for all implementation provided
iterator results (i.e. the String, Array and collection iterators,
and also for generators).  This removes one source of unnecessary
polymorphism in for-of loops.  It is accomplished by a new intrinsic
%_CreateIterResultObject() that should be used to create iterator
result objects from JavaScript builtins (there's a matching factory
method for C++ code).

Also restructure the %StringIteratorPrototype%.next() and
%ArrayIteratorPrototype%.next() functions to be a bit more friendly
to optimizing compilers.

BUG=

Review URL: https://codereview.chromium.org/1315903005

Cr-Commit-Position: refs/heads/master@{#30572}
parent d51c5885
......@@ -2280,8 +2280,9 @@ void FullCodeGenerator::EmitCreateIteratorResult(bool done) {
__ lw(a1, FieldMemOperand(a1, GlobalObject::kNativeContextOffset));
__ lw(a1, ContextOperand(a1, Context::ITERATOR_RESULT_MAP_INDEX));
__ pop(a2);
__ li(a3, Operand(isolate()->factory()->ToBoolean(done)));
__ li(t0, Operand(isolate()->factory()->empty_fixed_array()));
__ LoadRoot(a3,
done ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex);
__ LoadRoot(t0, Heap::kEmptyFixedArrayRootIndex);
__ sw(a1, FieldMemOperand(v0, HeapObject::kMapOffset));
__ sw(t0, FieldMemOperand(v0, JSObject::kPropertiesOffset));
__ sw(t0, FieldMemOperand(v0, JSObject::kElementsOffset));
......@@ -4498,9 +4499,8 @@ void FullCodeGenerator::EmitCreateIterResultObject(CallRuntime* expr) {
__ lw(a1, ContextOperand(cp, Context::GLOBAL_OBJECT_INDEX));
__ lw(a1, FieldMemOperand(a1, GlobalObject::kNativeContextOffset));
__ lw(a1, ContextOperand(a1, Context::ITERATOR_RESULT_MAP_INDEX));
__ pop(a3);
__ pop(a2);
__ li(t0, Operand(isolate()->factory()->empty_fixed_array()));
__ Pop(a2, a3);
__ LoadRoot(t0, Heap::kEmptyFixedArrayRootIndex);
__ sw(a1, FieldMemOperand(v0, HeapObject::kMapOffset));
__ sw(t0, FieldMemOperand(v0, JSObject::kPropertiesOffset));
__ sw(t0, FieldMemOperand(v0, JSObject::kElementsOffset));
......
......@@ -2278,11 +2278,12 @@ void FullCodeGenerator::EmitCreateIteratorResult(bool done) {
__ ld(a1, FieldMemOperand(a1, GlobalObject::kNativeContextOffset));
__ ld(a1, ContextOperand(a1, Context::ITERATOR_RESULT_MAP_INDEX));
__ pop(a2);
__ li(a3, Operand(isolate()->factory()->ToBoolean(done)));
__ li(t0, Operand(isolate()->factory()->empty_fixed_array()));
__ LoadRoot(a3,
done ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex);
__ LoadRoot(a4, Heap::kEmptyFixedArrayRootIndex);
__ sd(a1, FieldMemOperand(v0, HeapObject::kMapOffset));
__ sd(t0, FieldMemOperand(v0, JSObject::kPropertiesOffset));
__ sd(t0, FieldMemOperand(v0, JSObject::kElementsOffset));
__ sd(a4, FieldMemOperand(v0, JSObject::kPropertiesOffset));
__ sd(a4, FieldMemOperand(v0, JSObject::kElementsOffset));
__ sd(a2, FieldMemOperand(v0, JSIteratorResult::kValueOffset));
__ sd(a3, FieldMemOperand(v0, JSIteratorResult::kDoneOffset));
STATIC_ASSERT(JSIteratorResult::kSize == 5 * kPointerSize);
......@@ -4502,12 +4503,11 @@ void FullCodeGenerator::EmitCreateIterResultObject(CallRuntime* expr) {
__ ld(a1, ContextOperand(cp, Context::GLOBAL_OBJECT_INDEX));
__ ld(a1, FieldMemOperand(a1, GlobalObject::kNativeContextOffset));
__ ld(a1, ContextOperand(a1, Context::ITERATOR_RESULT_MAP_INDEX));
__ pop(a3);
__ pop(a2);
__ li(t0, Operand(isolate()->factory()->empty_fixed_array()));
__ Pop(a2, a3);
__ LoadRoot(a4, Heap::kEmptyFixedArrayRootIndex);
__ sd(a1, FieldMemOperand(v0, HeapObject::kMapOffset));
__ sd(t0, FieldMemOperand(v0, JSObject::kPropertiesOffset));
__ sd(t0, FieldMemOperand(v0, JSObject::kElementsOffset));
__ sd(a4, FieldMemOperand(v0, JSObject::kPropertiesOffset));
__ sd(a4, FieldMemOperand(v0, JSObject::kElementsOffset));
__ sd(a2, FieldMemOperand(v0, JSIteratorResult::kValueOffset));
__ sd(a3, FieldMemOperand(v0, JSIteratorResult::kDoneOffset));
STATIC_ASSERT(JSIteratorResult::kSize == 5 * kPointerSize);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment