OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 bool double_align = AllocateDoubleAlignFlag::decode(flags); | 283 bool double_align = AllocateDoubleAlignFlag::decode(flags); |
284 AllocationSpace space = AllocateTargetSpace::decode(flags); | 284 AllocationSpace space = AllocateTargetSpace::decode(flags); |
285 CHECK(size <= kMaxRegularHeapObjectSize || space == LO_SPACE); | 285 CHECK(size <= kMaxRegularHeapObjectSize || space == LO_SPACE); |
286 return *isolate->factory()->NewFillerObject(size, double_align, space); | 286 return *isolate->factory()->NewFillerObject(size, double_align, space); |
287 } | 287 } |
288 | 288 |
289 RUNTIME_FUNCTION(Runtime_AllocateSeqOneByteString) { | 289 RUNTIME_FUNCTION(Runtime_AllocateSeqOneByteString) { |
290 HandleScope scope(isolate); | 290 HandleScope scope(isolate); |
291 DCHECK_EQ(1, args.length()); | 291 DCHECK_EQ(1, args.length()); |
292 CONVERT_SMI_ARG_CHECKED(length, 0); | 292 CONVERT_SMI_ARG_CHECKED(length, 0); |
| 293 if (length == 0) return isolate->heap()->empty_string(); |
293 Handle<SeqOneByteString> result; | 294 Handle<SeqOneByteString> result; |
294 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 295 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
295 isolate, result, isolate->factory()->NewRawOneByteString(length)); | 296 isolate, result, isolate->factory()->NewRawOneByteString(length)); |
296 return *result; | 297 return *result; |
297 } | 298 } |
298 | 299 |
299 RUNTIME_FUNCTION(Runtime_AllocateSeqTwoByteString) { | 300 RUNTIME_FUNCTION(Runtime_AllocateSeqTwoByteString) { |
300 HandleScope scope(isolate); | 301 HandleScope scope(isolate); |
301 DCHECK_EQ(1, args.length()); | 302 DCHECK_EQ(1, args.length()); |
302 CONVERT_SMI_ARG_CHECKED(length, 0); | 303 CONVERT_SMI_ARG_CHECKED(length, 0); |
| 304 if (length == 0) return isolate->heap()->empty_string(); |
303 Handle<SeqTwoByteString> result; | 305 Handle<SeqTwoByteString> result; |
304 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 306 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
305 isolate, result, isolate->factory()->NewRawTwoByteString(length)); | 307 isolate, result, isolate->factory()->NewRawTwoByteString(length)); |
306 return *result; | 308 return *result; |
307 } | 309 } |
308 | 310 |
309 | 311 |
310 RUNTIME_FUNCTION(Runtime_IS_VAR) { | 312 RUNTIME_FUNCTION(Runtime_IS_VAR) { |
311 UNREACHABLE(); // implemented as macro in the parser | 313 UNREACHABLE(); // implemented as macro in the parser |
312 return NULL; | 314 return NULL; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 | 481 |
480 RUNTIME_FUNCTION(Runtime_Typeof) { | 482 RUNTIME_FUNCTION(Runtime_Typeof) { |
481 HandleScope scope(isolate); | 483 HandleScope scope(isolate); |
482 DCHECK_EQ(1, args.length()); | 484 DCHECK_EQ(1, args.length()); |
483 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 485 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
484 return *Object::TypeOf(isolate, object); | 486 return *Object::TypeOf(isolate, object); |
485 } | 487 } |
486 | 488 |
487 } // namespace internal | 489 } // namespace internal |
488 } // namespace v8 | 490 } // namespace v8 |
OLD | NEW |