It's performed using the PRF, as indicated by the RFC specifying the TLS 1.2 specification you pointed to. The PRF is identified by the cipher suite - commonly as last part of the cipher suite string.
How the PRF works is specified by section 5 of the TLS 1.2 specification:
In addition, a construction is required to do expansion of secrets
into blocks of data for the purposes of key generation or validation.
This pseudorandom function (PRF) takes as input a secret, a seed, and
an identifying label and produces an output of arbitrary length.
And the specification then says:
master_secret = PRF(pre_master_secret, "master secret",
ClientHello.random + ServerHello.random)
key_block = PRF(SecurityParameters.master_secret,
after which the output
key_block is split into the session keys required.
So the entire spec relies on the PRF, which relies on the iterated P_hash, which relies on HMAC_hash which relies, finally, on a secure hash such as SHA-256. Otherwise it is just concatenation and splits of octet string (also known as byte arrays). I won't copy the algorithms here, they are well described in the TLS specification.
As it doesn't rely on any other cryptographic primitives the cipher suite string simply lists the hash function used as configuration parameter for the PRF, for instance SHA-1 in TLS_RSA_WITH_AES_128_CBC_SHA and of course SHA-256 in TLS_RSA_WITH_AES_128_CBC_SHA256, both from appendix C of the specification.
Note that the DH handling of TLS 1.2 is a bit strange in the fact that it uses the minimal size encoding of the DH result as
pre_master_secret. Generally the output of DH Is considered static, and of the same size as the prime field (i.e. 1024 bit for 1024 bit DH). So you should not left-pad with zeros for TLS 1.2. This has been fixed in TLS 1.3 draft specification (to be precise after I mentioned it in the mailing list, in draft 13).
Note that the generation of keys using the PRF is generally known as (key based) key derivation. The PRF is therefore used as TLS-specific Key Based Key Derivation Function or KBKDF.