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

Side by Side Diff: src/arm/builtins-arm.cc

Issue 1440193003: [builtins] One runtime fallback is enough for the String constructor. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Use correct temp registers. Created 5 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 | « no previous file | src/arm64/builtins-arm64.cc » ('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 #if V8_TARGET_ARCH_ARM 5 #if V8_TARGET_ARCH_ARM
6 6
7 #include "src/codegen.h" 7 #include "src/codegen.h"
8 #include "src/debug/debug.h" 8 #include "src/debug/debug.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/full-codegen/full-codegen.h" 10 #include "src/full-codegen/full-codegen.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 ToStringStub stub(masm->isolate()); 244 ToStringStub stub(masm->isolate());
245 __ Push(r1, r3); 245 __ Push(r1, r3);
246 __ Move(r0, r2); 246 __ Move(r0, r2);
247 __ CallStub(&stub); 247 __ CallStub(&stub);
248 __ Move(r2, r0); 248 __ Move(r2, r0);
249 __ Pop(r1, r3); 249 __ Pop(r1, r3);
250 } 250 }
251 __ bind(&done_convert); 251 __ bind(&done_convert);
252 } 252 }
253 253
254 // 3. Allocate a JSValue wrapper for the string. 254 // 3. Check if original constructor and constructor differ.
255 Label new_object;
256 __ cmp(r1, r3);
257 __ b(ne, &new_object);
258
259 // 4. Allocate a JSValue wrapper for the string.
255 { 260 {
256 // ----------- S t a t e ------------- 261 // ----------- S t a t e -------------
257 // -- r2 : the first argument 262 // -- r2 : the first argument
258 // -- r1 : constructor function 263 // -- r1 : constructor function
259 // -- r3 : original constructor 264 // -- r3 : original constructor
260 // -- lr : return address 265 // -- lr : return address
261 // ----------------------------------- 266 // -----------------------------------
262 267 __ Allocate(JSValue::kSize, r0, r4, r5, &new_object, TAG_OBJECT);
263 Label allocate, done_allocate, rt_call;
264
265 // Fall back to runtime if the original constructor and function differ.
266 __ cmp(r1, r3);
267 __ b(ne, &rt_call);
268
269 __ Allocate(JSValue::kSize, r0, r3, r4, &allocate, TAG_OBJECT);
270 __ bind(&done_allocate);
271 268
272 // Initialize the JSValue in r0. 269 // Initialize the JSValue in r0.
273 __ LoadGlobalFunctionInitialMap(r1, r3, r4); 270 __ LoadGlobalFunctionInitialMap(r1, r3, r4);
274 __ str(r3, FieldMemOperand(r0, HeapObject::kMapOffset)); 271 __ str(r3, FieldMemOperand(r0, HeapObject::kMapOffset));
275 __ LoadRoot(r3, Heap::kEmptyFixedArrayRootIndex); 272 __ LoadRoot(r3, Heap::kEmptyFixedArrayRootIndex);
276 __ str(r3, FieldMemOperand(r0, JSObject::kPropertiesOffset)); 273 __ str(r3, FieldMemOperand(r0, JSObject::kPropertiesOffset));
277 __ str(r3, FieldMemOperand(r0, JSObject::kElementsOffset)); 274 __ str(r3, FieldMemOperand(r0, JSObject::kElementsOffset));
278 __ str(r2, FieldMemOperand(r0, JSValue::kValueOffset)); 275 __ str(r2, FieldMemOperand(r0, JSValue::kValueOffset));
279 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); 276 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize);
280 __ Ret(); 277 __ Ret();
278 }
281 279
282 // Fallback to the runtime to allocate in new space. 280 // 5. Fallback to the runtime to create new object.
283 __ bind(&allocate); 281 __ bind(&new_object);
284 { 282 {
285 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); 283 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
286 __ Move(r3, Smi::FromInt(JSValue::kSize)); 284 __ Push(r2, r1, r3); // first argument, constructor, original constructor
287 __ Push(r1, r2, r3); 285 __ CallRuntime(Runtime::kNewObject, 2);
288 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); 286 __ Pop(r2);
289 __ Pop(r1, r2);
290 }
291 __ b(&done_allocate);
292
293 // Fallback to the runtime to create new object.
294 __ bind(&rt_call);
295 {
296 FrameScope scope(masm, StackFrame::INTERNAL);
297 __ Push(r1, r2);
298 __ Push(r1, r3); // constructor function, original constructor
299 __ CallRuntime(Runtime::kNewObject, 2);
300 __ Pop(r1, r2);
301 }
302 __ str(r2, FieldMemOperand(r0, JSValue::kValueOffset));
303 __ Ret();
304 } 287 }
288 __ str(r2, FieldMemOperand(r0, JSValue::kValueOffset));
289 __ Ret();
305 } 290 }
306 291
307 292
308 static void CallRuntimePassFunction( 293 static void CallRuntimePassFunction(
309 MacroAssembler* masm, Runtime::FunctionId function_id) { 294 MacroAssembler* masm, Runtime::FunctionId function_id) {
310 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); 295 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
311 // Push a copy of the function onto the stack. 296 // Push a copy of the function onto the stack.
312 __ push(r1); 297 __ push(r1);
313 // Push function as parameter to the runtime call. 298 // Push function as parameter to the runtime call.
314 __ Push(r1); 299 __ Push(r1);
(...skipping 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after
1942 } 1927 }
1943 } 1928 }
1944 1929
1945 1930
1946 #undef __ 1931 #undef __
1947 1932
1948 } // namespace internal 1933 } // namespace internal
1949 } // namespace v8 1934 } // namespace v8
1950 1935
1951 #endif // V8_TARGET_ARCH_ARM 1936 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm64/builtins-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698