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

Side by Side Diff: src/runtime.cc

Issue 364853009: Implement ES6 Array.of() (Closed) Base URL: https://github.com/v8/v8@master
Patch Set: Fix indentation in harmony-array.js. Add comments to AddElement. Created 6 years, 4 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/runtime.h ('k') | test/mjsunit/harmony/array-of.js » ('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 <stdlib.h> 5 #include <stdlib.h>
6 #include <limits> 6 #include <limits>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 5344 matching lines...) Expand 10 before | Expand all | Expand 10 after
5355 StrictMode strict_mode = strict_mode_arg; 5355 StrictMode strict_mode = strict_mode_arg;
5356 5356
5357 Handle<Object> result; 5357 Handle<Object> result;
5358 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 5358 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
5359 isolate, result, 5359 isolate, result,
5360 Runtime::SetObjectProperty(isolate, object, key, value, strict_mode)); 5360 Runtime::SetObjectProperty(isolate, object, key, value, strict_mode));
5361 return *result; 5361 return *result;
5362 } 5362 }
5363 5363
5364 5364
5365 // Adds an element to an array.
5366 // This is used to create an indexed data property into an array.
5367 RUNTIME_FUNCTION(Runtime_AddElement) {
5368 HandleScope scope(isolate);
5369 RUNTIME_ASSERT(args.length() == 4);
5370
5371 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
5372 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
5373 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
5374 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3);
5375 RUNTIME_ASSERT(
5376 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
5377 // Compute attributes.
5378 PropertyAttributes attributes =
5379 static_cast<PropertyAttributes>(unchecked_attributes);
5380
5381 uint32_t index = 0;
5382 key->ToArrayIndex(&index);
5383
5384 Handle<Object> result;
5385 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
5386 isolate, result, JSObject::SetElement(object, index, value, attributes,
5387 SLOPPY, false, DEFINE_PROPERTY));
5388 return *result;
5389 }
5390
5391
5365 RUNTIME_FUNCTION(Runtime_TransitionElementsKind) { 5392 RUNTIME_FUNCTION(Runtime_TransitionElementsKind) {
5366 HandleScope scope(isolate); 5393 HandleScope scope(isolate);
5367 RUNTIME_ASSERT(args.length() == 2); 5394 RUNTIME_ASSERT(args.length() == 2);
5368 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); 5395 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0);
5369 CONVERT_ARG_HANDLE_CHECKED(Map, map, 1); 5396 CONVERT_ARG_HANDLE_CHECKED(Map, map, 1);
5370 JSObject::TransitionElementsKind(array, map->elements_kind()); 5397 JSObject::TransitionElementsKind(array, map->elements_kind());
5371 return *array; 5398 return *array;
5372 } 5399 }
5373 5400
5374 5401
(...skipping 10255 matching lines...) Expand 10 before | Expand all | Expand 10 after
15630 } 15657 }
15631 return NULL; 15658 return NULL;
15632 } 15659 }
15633 15660
15634 15661
15635 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { 15662 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
15636 return &(kIntrinsicFunctions[static_cast<int>(id)]); 15663 return &(kIntrinsicFunctions[static_cast<int>(id)]);
15637 } 15664 }
15638 15665
15639 } } // namespace v8::internal 15666 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | test/mjsunit/harmony/array-of.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698